dpb <none@non.net> wrote in message <jgm31q$ffn$1@speranza.aioe.org>...
> On 2/5/2012 7:50 AM, Chris Sorrento wrote:
> > I am trying to solve 3 differential equations simultaneously. But got
> > the following error.
> >
> > ??? Undefined function or variable 'X'.
> >
> > Error in ==> AGAPerfusion>Perfusion at 33
> > y(1) = Mu*X  kD*X + 9*X*y(2)  10*X*y(2);
> >
> > Error in ==> odearguments at 98
> > f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
> >
> > Error in ==> ode45 at 172
> > [neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...
> >
> > Error in ==> AGAPerfusion at 19
> > [T, Y] = ode45(@Nested, [0 30], [X0; F0; CO20]);
> >
> > I am wondering if the issue in my code below is due to improper
> > notation. But I am stumped as to how to change the notation for X.
> ...
>
> > [T, Y] = ode45(@Nested, [0 30], [X0; F0; CO20]);
> > plot(T,Y(:,1),'sr',T,Y(:,2),'+b',T,Y(:,3),'og')
> > disp(Y)
> > % y(1) = dXdt % y(2) = dF0dt
> > % y(3) = dCO2dt
> >
> > % Nested Function
> > function dy = Nested(t,y)
> >
> > dy = zeros(3,1);
> > y(1) = Mu*X  kD*X + 9*X*y(2)  10*X*y(2);
> > y(2) = qGLC*y(1);
> > y(3) = qCO2*y(1);
> > end
>
> [T,Y] = ODE45(ODEFUN,TSPAN,Y0,OPTIONS,P1,P2...) passes the additional
> parameters P1,P2,... to the ODE function as ODEFUN(T,Y,P1,P2...),
> and to all functions specified in OPTIONS. Use OPTIONS = [] as a place
> holder if no options are set.
>
> You didn't pass X (nor the constants) as additional parameters as per
> the documentation...hence they're unknown in the function.
>
Thanks dbp for your response. I put [] as you suggested. Also, on the right hand side, I changed from y(1), y(2) y(3) to dy(1), dy(2) dy(3) and then replaced X with y(1). That solved the problem! Thanks again.
