1
$\begingroup$

Ndsolve solution cant manipulate parametric plot!!

 ClearAll[x, y, θ];
 L = 1;

v1[t_] := 5 UnitStep[t - 10] - 5 UnitStep[t - 30];
v2[t_] := 4 UnitStep[t - 20] - 4 UnitStep[t - 50];
v3[t_] := 6 UnitStep[t - 50] - 6 UnitStep[t - 80];

eq1 = -2/3*Sin[θ[t]]*v1[t] - 
    2/3*Sin[Pi/3 - θ[t]]*v2[t] + 
    2/3*Sin[Pi/3 + θ[t]]*v3[t] - x'[t] == 0;
eq2 = 2/3*Cos[θ[t]]*v1[t] - 
    2/3*Cos[Pi/3 - θ[t]]*v2[t] - 
    2/3*Cos[Pi/3 + θ[t]]*v3[t] - y'[t] == 0;
eq3 = 1/3 L*(v1[t] + v2[t] + v3[t]) - θ'[t] == 0;
ics = {x[0] == 1, y[0] == 0, θ[0] == 0};
eqs = Join[{eq1, eq2, eq3}, ics];

sol = First@NDSolve[eqs, {x[t], y[t], θ[t]}, {t, 0, 100}];
Plot[Evaluate[{x[t], y[t], θ[t]} /. sol], {t, 0, 100}, 
     PlotStyle -> {{Thick, Red}, {Thick, Blue, Dashed}, {Thick, Black,  Dotted}}]

Manipulate[
 Graphics[Rotate[
   Rectangle[{Evaluate[{x[a]} /. sol], Evaluate[{y[a]} /. sol]}], 
   Evaluate[{θ[a]} /. sol]]], {a, 0.1, 100}]
$\endgroup$
  • $\begingroup$ One possibility: Replace {x[t], y[t], θ[t]} with {x, y, θ} in NDSolve, and get rid of the {}'s surrounding x[a], y[a], and θ[a] in your Manipulate expression. $\endgroup$ – march Jul 16 '15 at 20:44
1
$\begingroup$

Perhaps you want something like:

sol = First@NDSolve[eqs, {x, y, θ}, {t, 0, 100}];
Manipulate[Graphics[Rotate[Rectangle[{0, 0}, {y[a], x[a]}], θ[a]] /. sol,
                    Axes -> True], {a, 0.1, 100}]

Mathematica graphics

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.