Message Boards Message Boards

GROUPS:

Use ParametricPlot to show the results of NDSolve?

Posted 1 month ago
221 Views
|
2 Replies
|
1 Total Likes
|

Im trying to show the results of NdSolve by using Parametric Plot.These are pendulum equations and I want to get phase-space trajectories of this system. For small angles like Pi/5 i should get a circle.Here is my code

pend[\[Theta]0, \[Omega]0, \[Gamma], \[CurlyPhi]0, \[Omega]D, T] := 
  NDSolve[{\[Theta]'[t] == \[Omega][t], \[Omega]'[
      t] == -\[Gamma]\[Omega][t] - 
      Sin[\[Theta][t]] + \[CurlyPhi]0 Cos[\[Alpha][t]], \[Alpha]'[
      t] == \[Omega]D, \[Theta][0] == \[Theta]0, \[Omega][
      0] == \[Omega]0, \[Alpha][0] == 
     0}, {\[Theta], \[Omega], \[Alpha]}, {t, 0, T}];

sol1 = pend[Pi/5, 0, 0, 0, 0, 100];
ParametricPlot[
 Evaluate[{{\[Theta][t], \[Omega][t]} /. sol1}], {t, 0, 30}, 
 PlotRange -> All, Frame -> True]

I keep getting the error message that the result of NDSolve " is neither a list of replacement rules nor a valid dispatch table, so cannot be used for replacing". I don't know how to fix it. I would appreciate your help very much.

2 Replies

First of all, you should add the underscores in the function definition:

pend[\[Theta]0_, \[Omega]0_, \[Gamma]_, \[CurlyPhi]0_, \[Omega]D_, T_]

Then you should insert a space or a multiplication sign between the two letters \[Gamma]\[Omega]. You also may consider using NDSolveValue instead of NDSolve, to get a simpler syntax.

Thank you for your comment.Now everything works perfectly.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract