0
$\begingroup$

I am solving DE w/ parameters. It has many functions so I tried to automate using list but it is not working. Specifically, it does not give specific value even when all parameters are specified and the plot is empty. Here is a minimal example:

ylist = {y1[t], y2[t]};(*create list of functions to solve*)
m = {{a, b}, {c, d}};(*parameters arranged as matrix*)
ysol = ParametricNDSolve[Flatten[{Table[D[ylist[[i]], t] ==(m.ylist) 
[[i]], {i, 1, 2}],Table[(ylist[[j]] /. t -> 0) == 0, {j, 1, 2}]}],
ylist, {t, 0, 10}, {a, b, c, d}];

I expect the following to give a number but it does not:

ylist[1, 1, 1, 0][1] /. ysol

Consenquently, the plot is empty:

Plot[Re[Evaluate[ylist[1, 1, 1, 0][t] /. ysol]], {t, 0, 10}]

Any help much appreciated!

$\endgroup$
2
  • $\begingroup$ somey=(ylist/.ysol)[[1]][1,1,1,0] gives you InterpolatingFunction[stuff][t] so that looks like it has extracted your first function and inserted your parameters. Then somey/.t->2 looks like it gives you the value of your function at t==2 and it looks like your first function is zero when t==2 with those parameters. Then Table[somey,{t,0,10}] gives you {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.} Then Plot[somey+0.1,{t,0,10}] plots your function with a fudge factor added to get it off the x axis, so it looks like your function is zero everywhere. Are you SURE the solution is nonzero $\endgroup$
    – Bill
    Commented Aug 14, 2020 at 16:39
  • $\begingroup$ For this example, the answer is indeed zero. My original problem is that the code is not giving any result. I fixed it by changing the 2nd argument in ParametricNDSolve from ylist to {y1,y2}. That is, remove the argument t when specifying the functions to be solved. Same thing when calling the values: y1[1,1,1,0][1] yields the numerical result. $\endgroup$
    – khvillegas
    Commented Aug 16, 2020 at 6:47

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.