Not enough input arguments. Error in chp12ex7_b (line 3) X=y(1); T=y(2); HELP how do I fix this error?
1 view (last 30 days)
Show older comments
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
0 Comments
Answers (1)
Cris LaPierre
on 8 May 2021
Edited: Cris LaPierre
on 8 May 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?
0 Comments
See Also
Categories
Find more on Numerical Integration and Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!