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

답변 (1개)

Walter Roberson
Walter Roberson 2013년 11월 26일

0 개 추천

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

Jacob
Jacob 2013년 11월 26일
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 2013년 11월 26일
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)

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Programming에 대해 자세히 알아보기

질문:

2013년 11월 26일

댓글:

2013년 11월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by