Group Abstract Group Abstract

Message Boards Message Boards

Plot 2 parameter solution from ParametricNDSolve with Table

Posted 5 years ago

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,
y[0]==b},{x,y},{t,0,100},{a,b}].

When I try to plot with

pp = ParametricPlot[Evaluate@Table[{x[a,b][t],y[a,b][t]}/.twoeqnpara,
{a,-2,2,0.5},{b,-2,2,0.5}],{t,0,40},PlotRange->All]

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}],
{t,0,40},PlotRange->All,PlotLegends->Range[-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.

POSTED BY: Sahil Goyal
3 Replies

The code

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

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

Plot[x,{x,0,1}][[1]]

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.

POSTED BY: Gianluca Gorni
POSTED BY: Gianluca Gorni
Posted 5 years ago
POSTED BY: Sahil Goyal
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard