# Generate and plot different solutions with NDSolve with different conditions in one line

I have a set of equations pdes and some initial/boundary conditions bcs. These conditions depend on some parameters, which I can group as n sets,bcsi labeled by i where i=1,...,n.

When solving the equations (for one single set of conditions) I write

sols=NDSolveValue[{pdes,bcs},{y1[x],y2[x],...,yN[x]},{x,xi,xf}]


If I want to plot the solution, lets say y1[x], I write

ploty1=Plot[First@sols,{x,xi,xf}]


Now, if I want to solve the equations for each set of conditions, and then to plot, for example, y1[x] again, I would do the following

sol1=NDSolveValue[{pdes,bcs1},{y1[x],y2[x],...,yN[x]},{x,xi,xf}]
sol2=NDSolveValue[{pdes,bcs2},{y1[x],y2[x],...,yN[x]},{x,xi,xf}]
...
soln=NDSolveValue[{pdes,bcsn},{y1[x],y2[x],...,yN[x]},{x,xi,xf}]


and make plots in the same way, etc, and do the following

Plot[{First@sol1,...,First@soln},{x,xi,xf}]


to get the solutions for y1[x] depending on each set of conditions. Is there a way to construct this plot not solving for each set separately but as a List or Table, in such a way that just doing

Plot[First@solutions,{x,xi,xf}],


where solutions is the set of solutions for each condition, allows to see how y1 changes when I change the conditions?

• I would first put the boundary conditions in a table and then use sol=Table[NDSolveValue[{pdes,bcs[[i]]}],{i,1,n}] to get the solutions in one table. – egwene sedai Nov 7 '17 at 21:12
• If you're going to be varying the boundary conditions a lot, you might want to use ParametricNDSolveValue[] instead. – J. M.'s ennui Nov 7 '17 at 21:46

## 1 Answer

First put the conditions in a table

bcst={bcs1,...bcsn}


As suggested above, to solve the equations together

sols=Table[NDSolveValue[{pdes,bcst[[i]]},{y1[x],...,yN[x]},{x,xi,xf}],{i,1,n}]


to plot the curves for y1[x] for each condition, we write

Plot[Evaluate[Table[First@sols[[i]],{i,1,n}]],{x,xi,xf}]


Since we have n plots, one can give colors to each curve by setting n color inside PlotStyle