Using ode45 variables in non-differential equations

I'm looking to take the variables that I am using in my differential equations and apply a conversion to get the value for other variables that are functions of these variables.
That was very poorly worded so here is just an example of my code:
function dy = odeequation(t,y) dy = zeros(6,1);
z = y*(1-0.876*exp(-0.014*t));
dy(1) = some function;
...
dy(6) = some other function;
Before I did not have the dz term because this is my conversion. I want to plot z against time. How can I do that?
Thanks!

Answers (1)

Calculate z from the results you obtained for y after your call to the ODE-integrator:
[T,Y]=ode45(...);
for k=1:6
Z(:,k)=Y(:,k).*(1-0.876*exp(-0.014*T));
end
Best wishes
Torsten.

Tags

Asked:

on 29 Feb 2016

Answered:

on 1 Mar 2016

Community Treasure Hunt

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

Start Hunting!