Be the first to rate this file! 5 Downloads (last 30 days) File Size: 1.5 KB File ID: #27469

getODEderivatives()

by Luca Cerone

 

04 May 2010

Get derivatives of an ODE syste,

| Watch this File

File Information
Description

 Syntax: dydt=getODEderivatives(t,y,odehandler)
 
 This function is used to get the time course derivatives
 evaluated to solve an ode system using Matlab solvers
 (ode45,ode23,ode23s and so on).
 
 Example:
 
 Want to solve the system and plot the solution as well as how the derivatives change:
  dudt=w;
  dwdt=-u;
 
  u(0)=0;
  w(0)=1;
 
 odehandler=@(t,y) [y(2);-y(1)];
 [t,y]=ode45(odehandler,[0 4*pi],[0 1]);
 u=y(:,1);
 w=y(:,2);
 
 (select the code below and press F9 to run it).
 
 dydt=getODEderivatives(t,y,odehandler);
 dudt=dydt(:,1);
 dwdt=dydt(:,2);
 
  %Check that dudt=w;
 sum(dudt==w)==length(t)
 plot(t,dudt,'r--',t,w,'g-.')
 legend('dudt','w')
 
  %Check that dwdt=-u;
 sum(dwdt==-u)==length(t)
 figure
 plot(t,dwdt,'r--',t,-u,'g-.')
 legend('dwdt','-u')

MATLAB release MATLAB 7.9 (2009b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
ode Luca Cerone 04 May 2010 10:23:12
ode system Luca Cerone 04 May 2010 10:23:12
derivatives Luca Cerone 04 May 2010 10:23:12

Contact us at files@mathworks.com