Message Boards Message Boards


Plot 2 parameter solution from ParametricNDSolve with Table

Posted 24 days ago
3 Replies
2 Total Likes

I have a 2-D differential equation which I solve with ParametricNDSolve with initial time given as a parameters. I solve the equation using

twoeqnpara = ParametricNDSolve[{x'[t]==-3x[t] - y[t],y'[t] == x[t],x[0]==a,

When I try to plot with

pp = ParametricPlot[Evaluate@Table[{x[a,b][t],y[a,b][t]}/.twoeqnpara,

I don't get any plot. But when I do for single parameter

pp = ParametricPlot[Evaluate@Table[{x[a,a][t],y[a,a][t]}/.twoeqnpara,{a,-2,2,0.4}],

It works and give a plot.

What I think the issue is when I use the command

Table[ x+y, {x,-2,2,0.5},{y,-2,2,0.5}]

, what the command is taking a single value of x and all the values of y. What I need is all the pairs possible from the 2 arrays so that can be used as a initial condition for plotting.

3 Replies

This way it gives a plot:

twoeqnpara = ParametricNDSolveValue[
   {x'[t] == -3 x[t] - y[t], y'[t] == x[t], x[0] == a, y[0] == b},
   {x, y}, {t, 0, 100}, {a, b}];
ParametricPlot[Evaluate@Flatten[Table[Through[twoeqnpara[a, b][t]],
    {a, -2, 2, 0.5}, {b, -2, 2, 0.5}], 1],
 {t, 0, 100}, PlotRange -> All]
Posted 24 days ago

Thank You. Actually, I tried using Flatten, but didn't put a 1 there, that 1 changed the whole thing. Also, can you tell what is happening in this line of code

pp/.Line[x_]:>{Arrowheads[Table[.04, {4}]], Arrow[x]}

with pp being the output of the Parametric Plot command. It generates an arrow on the line of the plot, but I am not able to understand how it is being done.

Also, is there a way to use Table command with the pairs being generated by some function rather than


The code

pp/.Line[x_]:>{Arrowheads[Table[.04, {4}]], Arrow[x]}

targets the hidden internal structure of the output of Plot and ParametricPlot. Try


you will see that it contains a Line primitive, which your code replaces with an arrow. Table is compatible with the syntax Table[_,{pt_,{pts__}}], where the list of points {pts__} can be generated with a function.

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

Group Abstract Group Abstract