1
$\begingroup$

I can plot this code

ClearAll["Global`*"];
m = 2; a = 0;
r = 0.9;
timelimit = 35;
s = ParametricNDSolve[{m x''[t] + x'[t] == 
     Cos[r t - x[t]], x[0] == a, 
    x'[0] == r - v}, x, {t, 0, timelimit}, {v}];
Plot[Evaluate@Table[{x[v][t] /. s, v}, {v, -8, 2, 1}], {t, 0, 
  timelimit}]

enter image description here

But If I want to parametric, using the similar structure, like this

ClearAll["Global`*"];
m = 2; a = 0;
r = 0.9;
timelimit = 35;
s = ParametricNDSolve[{m x''[t] + x'[t] == Cos[r t - x[t]], x[0] == a, x'[0] == r - v}, x, {t, 0, timelimit}, {v}];
ParametricPlot[Evaluate@Table[{{r t - x[v][t], r - x[v][t]} /. s, v}, {v, -8, 2, 1}], {t, 0, timelimit}]

I can't get the output.

How can I get the Table ParametricPlot?

Thank you so much for your time!

$\endgroup$
6
  • $\begingroup$ ParametricPlot is for 2-dimensional curves, so it needs two values. You are providing three instead: {{r t - x[v][t], r - x[v][t]} /. s, v}. Use this: {r t - x[v][t], r - x[v][t]} /. s or use ParametricPlot3D if you want 3-dimensional curves. $\endgroup$
    – Domen
    Aug 18 at 17:21
  • $\begingroup$ v is the parameter. There still are two values? r t - x[v][t] and r - x[v][t] $\endgroup$
    – Yue Yu
    Aug 18 at 17:34
  • $\begingroup$ Yes, as I have said, use: ParametricPlot[Evaluate@Table[{r t - x[v][t], r - x[v][t]} /. s, {v, -8, 2, 1}], {t, 0, timelimit}]. $\endgroup$
    – Domen
    Aug 18 at 17:35
  • $\begingroup$ can you get the result using it? In the previous example of plot, we need to add ,v after /.s Plot[Evaluate@Table[{x[v][t] /. s, v}, {v, -8, 2, 1}], {t, 0, timelimit}] $\endgroup$
    – Yue Yu
    Aug 18 at 17:39
  • $\begingroup$ Yes, I get a plot, you don't? It should work. But perhaps this is not the plot you actually want. $\endgroup$
    – Domen
    Aug 18 at 17:45
2
$\begingroup$

As mentioned already in the comments, ParametricPlot is used for 2-dimensional curves, so you need to provide values in the form $\{f_x, f_y\}$:

Clear["Global`*"];
m = 2; a = 0;
r = 0.9;
timelimit = 35;
s = ParametricNDSolve[{m x''[t] + x'[t] == Cos[r t - x[t]], x[0] == a,
     x'[0] == r - v}, x, {t, 0, timelimit}, v];
ParametricPlot[
 Evaluate@Table[{r t - x[v][t], r - x[v][t]} /. s, {v, -8, 2, 1}], {t, 0, timelimit}]

Mathematica graphics

Should you want to have the parameter $v$ also be used as an axis, you have to use ParametricPlot3D:

ParametricPlot3D[
 Evaluate@Table[{r t - x[v][t], r - x[v][t], v} /. s, {v, -8, 2, 1}], {t, 0, timelimit}]

Mathematica graphics

$\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.