0
$\begingroup$

I want to plot 1100(r[t]-14) vs θ[t]. How can I plot the functions of r[t] and θ[t] from NDsolve? This is my code to find r[t] and θ[t]:

m = 81;
g = 9.81;
h = 12;
l = 15;
d = 15;
a = (d - h) \[Pi]/180;

s = NDSolve[{(m*g*
   Sin[\[Theta][t]]) - (m*(r''[t] - r[t] ((\[Theta]'[t])^2))) == 
1100 (r[t] - 14), g*Cos[\[Theta][t]] == 
r[t]*\[Theta]''[t] + 2*r'[t]*\[Theta]'[t], \[Theta][0] == 
ArcSin[a/l], \[Theta]'[0] == 0, r[0] == 15, r'[0] == 0}, {r, \[Theta]}, {t, 0, 100}]

And this is code that I use to make the plot:

ParametricPlot[ Evaluate[{1100*(r[t] - 14), \[Theta][t]} /. s], {t, 0, 2}, PlotPoints -> 200]
$\endgroup$
11
  • $\begingroup$ to use NDSolve, all parameters used need to have numerical values. $\endgroup$ Commented Apr 23, 2021 at 2:57
  • $\begingroup$ i already use ParametricPlot but i get nothing $\endgroup$ Commented Apr 23, 2021 at 3:19
  • $\begingroup$ That is not what I meant. You can't use NDSolve as you are doing. You need to provide numerical values for all the parameters in the ODE. $\endgroup$ Commented Apr 23, 2021 at 3:30
  • $\begingroup$ how can i provide numerical values $\endgroup$ Commented Apr 23, 2021 at 3:33
  • $\begingroup$ Well, it is your ODE. no one can guess what the numerical values for m and a and l. One can guess that g=9.81 assuming we are on earth. So if you want to use NDSolve, it will not work without these parameters having a numerical value. You are the only person who knows what these should be. $\endgroup$ Commented Apr 23, 2021 at 3:37

1 Answer 1

1
$\begingroup$
Clear["Global`*"]

m = 81;
g = 9.81;
h = 12;
l = 15;
d = 15;
a = (d - h) π/180;

s = NDSolve[
   {(m*g*Sin[θ[t]]) - (m*(r''[t] - r[t] ((θ'[t])^2))) ==
      1100 (r[t] - 14), 
    g*Cos[θ[t]] == r[t]*θ''[t] + 2*r'[t]*θ'[t],
    θ[0] == ArcSin[a/l], θ'[0] == 0, r[0] == 15, 
    r'[0] == 0},
   {r, θ}, {t, 0, 100}];

Manipulate[
 ParametricPlot[{1100 (r[t] - 14), θ[t]} /. s[[1]], {t, 0, 
   tmax},
  AspectRatio -> 1,
  ColorFunction -> Function[{x, y, t}, ColorData["Rainbow"][t]],
  PlotLegends -> BarLegend[{"Rainbow", {0, tmax}}]],
 {{tmax, 10}, 1, 100, 1, Appearance -> "Labeled"}]

enter image description here

$\endgroup$
2
  • $\begingroup$ oh!! i get it. It only put [1]after s right $\endgroup$ Commented Apr 23, 2021 at 3:56
  • $\begingroup$ It will plot with or without the [[1]]; however, to see the plot you cannot use the default AspectRatio $\endgroup$ Commented Apr 23, 2021 at 4:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.