Not enough input arguments. Error in chp12ex7_b (line 3) X=y(1); T=y(2); HELP how do I fix this error?

1 Ansicht (letzte 30 Tage)
script
clear
clc
%adibatic
v0=[0 305];
zspan=[0 10];
[z, v]=ode45(@chp12ex7_b, zspan, v0);
Cao=0.1; dH=-6000;
X = v(:,1); T = v(:,2);
k=0.01*exp((5033)*(1/300-1./T)); Kc=10.*exp((dH./1.987)*(1/450-1./T));
Xeq=(2.*Cao.*Kc+1-sqrt(4.*Cao.*Kc+1))./(2.*Cao.*Kc);
rate=-k.*((Cao.^2)*((1-X).^2)-Cao*X./Kc);
plot(z, v(:,1), z, Xeq), xlabel ('Volume (dm^3)'), ylabel ('Conversion'), legend('X','Xe'), title('Adiabatic')
figure
plot(z, v(:,2)), xlabel ('Volume (dm^3)'), ylabel ('Temperature'), legend('T'), title('Adiabatic')
figure
plot(z, -rate, 'k-'), xlabel ('Volume (dm^3)'), ylabel ('rate'), title('Adiabatic')
function
function ydot = chp12ex7_b(~,y)
%input variables
X=y(1); T=y(2);
%data
Ua=0; Cao=0.1; Fao=0.2; dH=-6000; Cpo=30; Ta = 0;
%rate
k=0.01*exp((5033)*(1/300-1/T)); Kc=10*exp((dH/1.987)*(1/450-1/T));
rate=-k*((Cao^2)*((1-X).^2)-Cao.*X./Kc);
%Equations
ydot(1)=-rate/Fao; ydot(2)=((rate*dH)-Ua*(T-Ta))/(Cpo*Fao);
ydot=ydot';
end

Antworten (1)

Cris LaPierre
Cris LaPierre am 8 Mai 2021
Bearbeitet: Cris LaPierre am 8 Mai 2021
Your code runs (see the outputs in your original post now). Do you still see the error? If so, consider clearing your workspace (though your script does this...). Maybe restart MATLAB?

Kategorien

Mehr zu Numerical Integration and Differential Equations finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by