manipulate后面不能跟,但是我之前写的一个长的类似的为什么可以
mathematica吧
全部回复
仅看楼主
level 2
(*第二题*)
Clear[l, m, a, b, \[Theta]1, \[Theta]2, L, funcs, sol];
Clear["Global`*"];
{g, m, A, \[Omega]0} = {9.81, 1, 2, 1};
l = g/(\[Omega]0^2);
Manipulate[
x = A*Cos[\[Omega]*t] + l*Sin[\[Theta][t]];
y = -l*Cos[\[Theta][t]];
funcs = {D[D[x, t], t]*Cos[\[Theta][t]] +
D[D[y, t], t]*Sin[\[Theta][t]] ==
g*Sin[\[Theta][t]], \[Theta][0] == 0, \[Theta]'[0] == 0};
sol = Quiet@
NDSolve[funcs, \[Theta], {t, 0, 10},
Method -> {"IndexReduction" -> {True,
"ConstraintMethod" -> "Projection"}}];, {\[Omega], 0.5, 3}]
p[t_] = {A*Cos[\[Omega]*t] + l*Sin[\[Theta][t]], -l*Cos[\[Theta][t]]};
Animate[{Show[
Graphics[{{Thickness[0.01],
Line[{{A*Cos[\[Omega]*t],
0}, {A*Cos[\[Omega]*t] + l*Sin[\[Theta][t]], -l*
Cos[\[Theta][t]]}}]},
Disk[{A*Cos[\[Omega]*t] + l*Sin[\[Theta][t]], -l*
Cos[\[Theta][t]]}, 0.015]} /. sol[[1]],
PlotRange -> {{-2.1, 2.1}, {2.1, -2.1}}, Frame -> True],
If[t < 3,
ParametricPlot[p[u] /. sol[[1]], {u, 0, t},
ColorFunction ->
Function[{x, y, t}, f = Hue[0.58, 0.58, 0.8, t]]],
ParametricPlot[p[u] /. sol[[1]], {u, t - 3, t},
ColorFunction ->
Function[{x, y, t}, f = Hue[0.58, 0.58, 0.8, t]]]]]}, {t,
0.00000001, 10}, SaveDefinitions -> True, AnimationRunning -> False,
RefreshRate -> 30]
2023年07月02日 09点07分 1
吧务
level 10
两处中文分号、omega没有值。
可能还有其他问题
2023年07月02日 18点07分 2
哦哦哦,知道了谢谢
2023年07月04日 03点07分
1