help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

moving calculation of a variable outside of function


From: Jim Maas
Subject: moving calculation of a variable outside of function
Date: Wed, 25 Mar 2009 11:39:25 +0000
User-agent: Thunderbird 2.0.0.21 (X11/20090318)

In the following code, is there a way to move the calculation of "ca" to a place outside the function, such that it's value will be available to other functions as well? This current code works for a single pool but I want to expand it to several pools and will need to use the same value of ca in other functions?

Thanks

Jim


----
Jim Maas


%-----------------------------------------------------------------------
% File mmsinglepool script file
% Demonstrate how to single pool model using ODE
% Corresponds to mmsinglepool.odg diagram
% Call ODE45
% Dr. Jim Maas
% 25/03/09
%-----------------------------------------------------------------------


% Read/assign model parameters -----------------------------------------
    vmax = 36.79;
    km   = 0.22;
    sz = 115.0;
    qin  = 18.63;

% Initial values -------------------------------------------------------
    qa0=25.0;

% Auxillary Equations---------------------------------------------------

    dqadt = @(t,y)(qin - qaout(t,y,vmax,km,sz));


    function [out,ca] = qaout(t,y,vmax,km,sz)
      ca = y/sz;
      out = vmax/(1+km/ca);
    endfunction
    
% Call a routine to solve ODE ------------------------------------------

   [t, y] = ode45 (dqadt, [0:0.1:10], qa0);            %Octave

% print/plot results ---------------------------------------------------
    plot(t,y);
    xlabel('TIME'); ylabel('QUANTITY');


reply via email to

[Prev in Thread] Current Thread [Next in Thread]