Error in script - 'undefined function'
Mostrar comentarios más antiguos
Hi all!
I'm new to Matlab so am encountering many problems. Here, I have written a script laying out the variables of an ODE which I will later attempt to solve using ode45. However, when I try to call the function it gives me this messgae. (Context: Xo and Xi are the volumes of water in the outer and inner layer of a leaf respectively, where Xo + Xi = 1).
I have tried to figure out the problem using online help but to no avail so any help would be greatly appreciated!

Respuestas (1)
madhan ravi
el 17 de Nov. de 2018
0 votos
Xi must be a numerical value , in your case you didn't define it which causes error
9 comentarios
Daniella Crispi
el 17 de Nov. de 2018
madhan ravi
el 17 de Nov. de 2018
Editada: madhan ravi
el 17 de Nov. de 2018
I have no idea what you did but I solved it in terms as function of t
t=[0 1]; %time interval
y0=[0 0] %initial conditions
[t,x]=ode45(@myod,t,y0);
plot(t,x)
function dxdt = myod(t,x)
%x(1)->Xo
%x(2)->Xi
a=3600;
b=3600;
uh=3; %fake data
ua=2; %fake data
uc=7; %fake data
mu=7; %fake data
x(1)=1-x(2);
dxdt=zeros(2,1);
dxdt(1)=(a*x(1).^2)./(x(1).^2+x(2).^2)+uh+ua-uc-mu.*x(1);
dxdt(2)=(a*x(2).^2)./(x(1).^2+x(2).^2)-uh-ua+uc-mu.*x(2);
end
Daniella Crispi
el 17 de Nov. de 2018
madhan ravi
el 17 de Nov. de 2018
As mentioned earlier the values have to be numerical, you can copy my answer and save it as a script file and then run it
Daniella Crispi
el 17 de Nov. de 2018
Stephen23
el 17 de Nov. de 2018
"Their values are dependent on Xo and Xi though."
Then parameterize the function using either nested functions or an anonymous function:
Daniella Crispi
el 17 de Nov. de 2018
Daniella Crispi
el 17 de Nov. de 2018
Daniella Crispi
el 17 de Nov. de 2018
Categorías
Más información sobre Ordinary Differential Equations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


