I'm doing a double pendulum system and I wish to plot the phase portraits for each angle. I've successfully used NDSolve to solve for each of the angles. Let's just work with one angle.

What's confusing me is how $\theta$ is a function of time $t$ and I'm not sure how to "write out" $\theta'$ as a function of $\theta$. I've seen other questions and have read the answers on StreamPlot, but I find it a little confusing.

My main confusion is with the actual arguments for StreamPlot. I want to plot $\theta '$ as a function of $\theta$ (which itself is a function of $t$) over the range, say, {t, 0, 100}. But looking at the documentation for StreamPlot, it tells me I need {vx, vy} over {x, 0, 100} and {y, 0, 100}. I'm not understanding how I can turn this into something with only one variable t.

According to documentation:

enter image description here

I'm assuming we want to work with {θ'[θ], θ[t]} and (for example) {θ, 0, 100}, {t, 0, 100} which would "[generate] a stream plot of the vector field {θ'[θ], θ[t]} as a function of θ and t."

So I try:

 {Subscript[\[θ], 2]'[Subscript[\[θ], 2]] /. sol, 
 Subscript[\[θ], 2][t] /. sol}, {Subscript[\[θ], 2], 0, 
  100}, {t, 0, 100}, StreamColorFunction -> "Rainbow"

enter image description here

I have no idea if this is the correct plot. I'm asking: is my syntax correct for the arguments of StreamPlot if I desire to plot $θ'(θ)$?

Edit: here is my code, though I'm more looking for a general solution to my problem of "how to put in the paramters into StreamPlot":

Subscript[m, 1] = 2;
Subscript[m, 2] = 1;
Subscript[l, 1] = 1;
Subscript[l, 2] = 4;
g = 9.8;
sol = First[
   NDSolve[{Subscript[l, 1]*
        Subscript[θ, 1]''[
         t]*(Subscript[m, 1] + Subscript[m, 2]) + 
       Subscript[m, 2]*Subscript[l, 2]*Subscript[θ, 2]''[t]*
        Cos[Subscript[θ, 1][t] - Subscript[θ, 2][t]] + 
       Subscript[m, 2]*Subscript[l, 2]*(Subscript[θ, 2]'[t])^2*
        Sin[Subscript[θ, 1][t] - Subscript[θ, 2][t]] + 
       g*(Subscript[m, 1] + Subscript[m, 2])*
        Sin[Subscript[θ, 1][t]] == 0,

     Subscript[m, 2]*Subscript[l, 2]*Subscript[θ, 2]''[t] + 
       Subscript[m, 2]*Subscript[l, 1]*Subscript[θ, 1]''[t]*
        Cos[Subscript[θ, 1][t] - Subscript[θ, 2][t]] - 
       Subscript[m, 2]*Subscript[l, 1]*(Subscript[θ, 1]'[t])^2*
        Sin[Subscript[θ, 1][t] - Subscript[θ, 2][t]] + 
       Subscript[m, 2]*g*Sin[Subscript[θ, 2][t]] == 0,
     Subscript[θ, 1][0] == Pi, 
     Subscript[θ, 2][0] == Pi/2, 
     Subscript[θ, 1]'[0] == 0, Subscript[θ, 2]'[0] == 0},
    {Subscript[θ, 1], Subscript[θ, 2]},
    {t, 0, 1000}]
  • $\begingroup$ You need to provide sol I'm afraid. $\endgroup$ – Öskå Nov 24 '14 at 10:31
  • $\begingroup$ Sure thing, I'll provide more code, but I was mainly looking for a general solution to my problem. Like say I have x[t]/.sol and x'[t]/.sol, how would I plot the phase portrait? $\endgroup$ – Sultan of Swing Nov 24 '14 at 10:34
  • $\begingroup$ This seems to be a duplicate of Phase portraits and StreamPlot $\endgroup$ – Artes Nov 24 '14 at 10:34
  • $\begingroup$ @Artes what I"m not getting is how to actually put in the parameters for StreamPlot. I'm using that question as a guide but I'm not "getting it" for some reason. $\endgroup$ – Sultan of Swing Nov 24 '14 at 10:35
  • $\begingroup$ I don't think that's the issue at this point (yes I have tried some other things and haven't gotten Subscript errors). The documentation for StreamPlot says to use {vx, vy}, and then a range for each x and y. My confusion stems from the fact that I'm using {theta1, theta1'} and a range for t. $\endgroup$ – Sultan of Swing Nov 24 '14 at 10:41

Your Answer

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

Browse other questions tagged or ask your own question.