1
$\begingroup$

I want to plot x'[t] as a function of x[t] (phase space) with PararametricPlot but mathematica shows nothing i dont understand what the problem is.this is my code:

k = 1;
m = 1;
w0 = Sqrt[k/m];
b = .1;
a0 = 0;
wd = 0;
ftotal[k_, x_, m_, b_, v_, a0_, wd_, t] := -k x - m b v + 
m a0 Cos[wd t];
s = First@
NDSolve[{ftotal[k, x[t], m, b, x'[t], a0, wd, t] == m x''[t], 
x[0] == 1, x'[0] == 0}, x[t], {t, 0, 100}]
Plot[Evaluate[x[t] /. s], {t, 0, 100}, AxesLabel -> {x[t], t}, 
PlotRange -> All]
ParametricPlot[{x[t], x'[t]} /. s, {t, 0, 20}, 
 AxesLabel -> {x[t], x'[t]}]
$\endgroup$
  • 1
    $\begingroup$ To make things clearer I would define sol[t_] = x[t] /. s and then plot {sol[t], sol'[t]}. $\endgroup$ – b.gates.you.know.what Feb 21 '18 at 9:51
  • $\begingroup$ y = D[x[t] /. s, t]; ParametricPlot[{x[t], y} /. s, {t, 0, 20}] $\endgroup$ – LouisB Feb 21 '18 at 9:55
3
$\begingroup$

enter image description here

       sol = First@
        NDSolve[{ftotal[k, x[t], m, b, x'[t], a0, wd, t] == m x''[t], 
        x[0] == 1, x'[0] == 0}, x, {t, 0, 100}] 
      ParametricPlot[Evaluate[{x[t], x'[t]} /. sol], {t, 0, 100}, 
       Frame -> True, PlotStyle -> Blue, 
       FrameLabel -> {Style["x[t]", 15], Style["x'[t]", 15]}, 
       FrameStyle -> Directive[Thick, 15], 
      LabelStyle -> Directive[Black, 15], ImageSize -> 500, 
        PlotRange -> All]
$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.