Output of sink / source terms when solving ODEs

1 view (last 30 days)
Hi there.
I'm running a simple series of ODEs using ode113. My model is behaving itself, but I want to understand what's happening with the sink and source terms (i.e. those terms that make up the dX / dt equation). I currently use a "OutputFcn" option that simply appends these to a global array that I can interrogate later.
function [status] = get_process(t, y, flag);
% Sets up process outputs
% Note : I've not worked out yet why this has a different time frame on it to the state variable outputs.
global tmp_processes processes;
processes = [processes; tmp_processes];
status = 0;
However, while my model does appear to behave itself, I can't square the sinks and sources it uses. I'm suspicious that the simple function above might be resulting in errors because it produces output on a somewhat different timeline from the main model (i.e. I have state variables on one time axis, the above on another).
Anyway, my question is what's the best way to access accurate sink and source terms from an ODE model in Matlab? I can't find much help from the Mathworks site on the "OutputFcn" option, but I'm assuming lots of people have the exact same problem to solve.
Thanks in advance!
Andrew

Answers (0)

Products


Release

R2013a

Community Treasure Hunt

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

Start Hunting!