Problem Solving 2 Ordinary Differential equations

What I have is.
function Dialysis=dc(t,c)
global k
V1=.70*33.2; %Intracellular fluid pool which is 70 percent of the total fluid volume of 33.2 liters
V2=.30*33.2; %Extracellular fluid pool which is 30 percent of the total fluid volume of 33.2 liters
g=.180; %urea production rate [g/hr]
b=4.61; %dialysis blood flow: [ltr/hr]
c=[c1;c2]; %Dependent variable c is a vector
c1=.63; %starting urea concentration in V1
c2=.63; %starting urea concentration in V2
dc1=(g-k*(c1-c2))/V1; %Equation governing the intracellular compartment
if (t>=1 & t<=3)
if(t>=25 & t<=27)
if(t>=49 & t<=51)
if(t>=73 & t<=75)
if(t>=87 & t<=89)
dc2=(k*(c1-c2)-b*c2)/V2;
else dc2=(k*(c1-c2))/V2;
end
dc=[dc1;dc2];
I am trying to call upon this funtion in another m file between times 0-99 hours. But all i receive are errors. How do I properely run this function so that it shows the model data c2 vs. t?
PLEASE HELP

Respuestas (1)

Walter Roberson
Walter Roberson el 26 de Nov. de 2013

0 votos

Do not give a variable the same name as your function.
Do assign a value to the name given on the left side of the "=" in your function statement (i.e., Dialysis)

3 comentarios

Jacob
Jacob el 26 de Nov. de 2013
Im sorry, a little confused on what youre trying to say.
Trying to clarify when i try to run the function by doing:
function dc %Calls the Function
[t,y] = ode45('Dialysis',[0, 99],[.63,.63])
My command window read:
Error using nargin Error: File: Dialysis.m Line: 4 Column: 1 Function definitions are not permitted in this context.
Error in odearguments (line 61) if (nargin(ode) == 2)
Error in ode45 (line 114) [neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...
Error in Dc (line 2) [t,y] = ode45('Dialysis',[0, 99],[.63,.63])
Please show the first five lines of the file Dialysis.m
Jacob
Jacob el 26 de Nov. de 2013
The first lines are just commented as my name and such...the first line of code is on line 5,function Dialysis=dc(t,c)

Iniciar sesión para comentar.

Categorías

Más información sobre Programming en Centro de ayuda y File Exchange.

Preguntada:

el 26 de Nov. de 2013

Comentada:

el 26 de Nov. de 2013

Community Treasure Hunt

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

Start Hunting!

Translated by