How do you pass a matrix (parameter) to decic and ode15i?
4 views (last 30 days)
I am using ode15i, with decic to determine consistent initial conditions for a differential equation that involves a matrix. However, when I call these functions, I want to be able to input my matrix at the same time. That is, everything works perfectly if I have my function fun(t,x,xprime), and solve it using:
[xhat,y]=decic(@fun,0,v,v,w,w), (where v and w are vectors).
But I want to be able to add a matrix input in "fun" (so that it is called with fun(C,t,x,xprime), so I am looking for something like
where C is some matrix that I have defined earlier in the command window. This syntax does not work though ("not enough input arguments"). How do I input a previously defined matrix into a function within decic/ode15i?
John Chilleri on 22 Jan 2017
Edited: John Chilleri on 22 Jan 2017
Rather than having to include your matrix in the decic/ode15i functions as an input, you could declare your matrix as a global variable, and access it in your function fun.
If you haven't heard of global variables, you can find information here.
C = some matrix you have;
Call ode15i as normal;
function outputs = fun(t,x)
Use C as needed;
Hope this helps!