function requires more input arguments to run
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Sujay Bharadwaj
el 7 de Nov. de 2021
Comentada: Image Analyst
el 8 de Nov. de 2021
function [ dydt ]=a14(t,y)
mumax=0.5;
ks=1;
ki=3;
k=14;
i0=75;
a=0.014;
Yi=0.5;
kla=0.00095;
h=0.00316;
sgin=0.06;
%dydt=zeroes(size(y));
x=y(1);
sl=y(2);
sg=y(3);
i=i0/a*x*(1-exp(-a*x));
mu=mumax*sl/((sl+ks+sl^2/ki)*(i/i+k));
dydt(1)=mu*x;
dydt(2)=kla*((sg/h)-sl)- Yi*dydt(1);
dydt(3)=sgin-kla*((sg/h)-sl);
tspan=[0 9];
y0=[0.03 0 17];
[t,y]=ode45(@a14,tspan,y0);
subplot(2,2,1);
plot(t,y(:,2),'-',t,y(:,1),':',t,y(:,3));
legend('Sl','x','Sg','location','east','bold');
xlabel('time,d');
ylabel('conc.,g/L');
subplot(2,2,2);
plot(t,y(:,1),'-');
axis([0 10 0 1.2]);
xlabel('time,d');
ylabel('biomass,g/L');
subplot(2,2,3);
plot(t,y(:,2),'red');
axis([0 10 0 20]);
xlabel('time,d');
ylabel('Sl,g/L');
subplot(2,2,4);
plot(t,y(:,3),'-');
axis([0 10 0 20]);
xlabel('time,d');
ylabel('Sg,g/L');
tspan=[0 9];
y0=[0.03 0 17];
[t,y]=ode45(@a14,tspan,y0);
%hold off
end
0 comentarios
Respuesta aceptada
Jan
el 7 de Nov. de 2021
The call of ODE45 is inlcuded in the function to be integrated - twice. I guess, that you see the error message, when you click on the green triangle in the editor, which calls the function without input arguments.
The solution is to create a new file and separate the function to be integrated from the call of ODE45:
% Before the definition of the function!
tspan = [0 9];
y0 = [0.03 0 17];
[t,y] = ode45(@a14, tspan, y0);
plot(t, y);
function [ dydt ]=a14(t,y)
mumax=0.5;
ks=1;
ki=3;
k=14;
i0=75;
a=0.014;
Yi=0.5;
kla=0.00095;
h=0.00316;
sgin=0.06;
x = y(1);
sl = y(2);
sg = y(3);
i = i0/a*x*(1-exp(-a*x));
mu=mumax*sl/((sl+ks+sl^2/ki)*(i/i+k));
dydt = zeros(size(y)); % Required to reply a column vector
dydt(1) = mu*x;
dydt(2) = kla*((sg/h)-sl)- Yi*dydt(1);
dydt(3) = sgin-kla*((sg/h)-sl);
end
Más respuestas (1)
Image Analyst
el 7 de Nov. de 2021
You forgot to show us the error! Here's another chance to read the posting guidelines:
Once you read that you'll learn you need to post ALL THE RED TEXT.
We have no idea what you passed in for t and y. For example, did you do this:
t = 10;
y = rand(5, 10);
[ dydt ]=a14(t,y)
Or did you not even define t and y and just clicked the green run triangle assuming MATLAB would somehow pick default values for t and y that would be acceptable for you? Because that won't happen.
6 comentarios
Image Analyst
el 8 de Nov. de 2021
y(:, 1) has a max of 0.03208 but you're setting the upper limit for the y axis to be 1.2. Change it to something smaller:
axis([0 10 0 0.04]);
Ver también
Categorías
Más información sobre Creating, Deleting, and Querying Graphics Objects en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

