Vector forcing a system of ODEs

7 views (last 30 days)
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

Linford Briant
Linford Briant on 16 Oct 2012
Edited: Linford Briant on 16 Oct 2012
To update you all... I am even more baffled, because the solver seems to correctly find solutions to the system if I set
ft=[0:0.01:5e4];
f=0.01*cos(0.002*ft);
This is a massive simplification of the forcing vector I would like to use, but I used it as a test to see if my ode code was correct... looks like it is, but the problem may lie with the vector I am trying to force the system with.
Perhaps my vector has a timestep that is too small (0.025ms), but it works for a cosine vector of the same timestep.
So I am thinking that it is the forcing function that is the problem and leading to the error:
Warning: Matrix is singular, close to singular or badly scaled.
Results may be inaccurate. RCOND = NaN.
But the system, when simulated in XPPAUT, is able to find a solution...
  1 Comment
Linford Briant
Linford Briant on 16 Oct 2012
It would seem maybe that I need to adjust tspan accordingly (duh!!) but if anyone has anything to add to this, that would be great!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!