Hi Guys
Please refer to the attached notebook.
It is something simple, for a bigger project.
How do I get the plots to work using Manipulate? The notebook does not run currently with the plotting function.
Hi Guys
Please refer to the attached notebook.
It is something simple, for a bigger project.
How do I get the plots to work using Manipulate? The notebook does not run currently with the plotting function.
A syntax problem. Your definition of S ends with a comma. Replace it with a semicolon.
Manipulate[
c = 0.1*k*m;
F = 1000;
S = NDSolve[{m*x''[t] + k*x[t] == F*Sin[w*t], x'[0] == 0, x[0] == 0}, x, {t, 0, 20}];
Plot[{x[t], x'[t], x''[t]} /. S, {t, 0, 20}, PlotLegends -> {"x", "y", "Theta"}],
{k, 50, 266*1000}, {m, 100, 1000}, {w, 10, 1000}
]
A part from that, I would insert an Evaluate inside Plot:
Manipulate[c = 0.1*k*m;
F = 1000;
S = NDSolve[{m*x''[t] + k*x[t] == F*Sin[w*t], x'[0] == 0, x[0] == 0},
x, {t, 0, 20}];
Plot[Evaluate[{x[t], x'[t], x''[t]} /. S], {t, 0, 20},
PlotLegends -> {"x", "y", "Theta"}], {k, 50, 266*1000}, {m, 100,
1000}, {w, 10, 1000}]
or, even better, use NDSolveValue:
Manipulate[c = 0.1*k*m;
F = 1000;
sol = NDSolveValue[{m*x''[t] + k*x[t] == F*Sin[w*t], x'[0] == 0,
x[0] == 0}, x, {t, 0, 20}];
Plot[{sol[t], sol'[t], sol''[t]}, {t, 0, 20},
PlotLegends -> {"x", "y", "Theta"}], {k, 50, 266*1000}, {m, 100,
1000}, {w, 10, 1000}]
Thank you kindly