I sent this to the wrong address <mbc195-tf(a)lists.fas.harvard.edu>
instead of <mcb195-tf(a)lists.fas.harvard.edu>
the first time.
On Wed, 2005-02-02 at 17:40 -0500, zucker wrote:
Hi Michael,
Some confusion:
The file called FirstOrder.m calls a function called FirstOrderODE
The file called FirstOrderODE.m contains a function called FirstOrder.
Shouldn't the function contained in FirstOrderODE.m be called FirstOrderODE?
Sincerely,
Jeremy
Michael Springer wrote:
Looks good.
A couple of minor changes.
The first problems set on the assignment page has the wrong due date.
Here are updated version of the matlab tutorial and problem set 1.
Also here are two m-files that should be put in the matlab tutorial
folder so people can download them.
Thanks,
Mike
------------------------------------------------------------------------
function out = FirstOrder(t,input,param)
%Constants
kdecay=param(1);
%Inputs
A=input(1);
B=input(2);
%Differential Equations
out(1,1)=-kdecay*A;
out(2,1)=+kdecay*A;
------------------------------------------------------------------------
%This is the file which will call up the ODE file to perform our numerical integration
%Constants
%param is our array of constants
kdecay=1;
param=[kdecay];
%initial values
%Remember from our ODE file A need to be the first element of the array and B the %second
element of the array.
A=100;
B=0;
initvals=[A B];
%Accuracy of our integrate : Don't worry about this line. In fact you don't
need to %include this; but you might want to use this some time down the road
%1e-10 mean 1*10^-10
options=odeset('AbsTol', 1e-6, 'RelTol', 1e-6);
%Set the Time length of the experiment
%In this case the system will start at time zero and integrate to time 100 seconds
tspan=[0 100];
%This next line is the meat and potatoes of the program. This line does calls our ODE
file and does %the integration. There are several different types of numerical
integrates. This is %beyond the scope of this class.
[t x]=ode23t(@FirstOrderODE,tspan,initvals,options,param);
%Watch your capitalization!!!
%Graph the output
figure;
plot(t,x);
xlabel('time')
ylabel('Concentration')
title('First Order Decay')