Vector forcing a system of ODEs
Show older comments
Hi Mathworks,
I am using a time-dependent parameter in a system of ODEs - i.e. a vector is called at every timestep to force the system of differential equation. A good example of this being used is in the page for ode23, Example 3:
Now my system is quite stiff, and so I must use ode15s to solve it. Under no forcing (or time-independent/constant parameters) the folowing code is able to solve the system, and produces output as in the literature:
[t,x]=ode15s(@transmission,tspan,[0,0,0]);
When I introduce this vector 'forcing', I add the following code to the transmission.m file:
f = interp1(ft,f,t);
And add the following arguments to transmission.m (or to the first line of transmission.m):
function xprime = transmission(t,x,ft,f);
Now when I call this function, I must first load the time and value vectors for the forcing vector - ft and f. Suppose these have been loaded into the workspace, then the following code should solve the system of differential equations:
[t,x] = ode15s(@(t,x) transmission(t,x,ft,f),tspan,[0,0,0]);
Although it doesn't work - " Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN."
It works better in ode45, but the solution vector is just "NaN", i.e. it didn't work. Can someone help me get ode15s to work for this forced system please :)
Moreover, can someone explain what the argument
@(t,x) transmission(t,x,ft,f)
to ode15s means/is doing - I am used to the normal arguments for ode functions but I don't understand this one.
Thanks,
Linford
Accepted Answer
More Answers (0)
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!