Undefined function or variable 'z' and error with ode45.
Afficher commentaires plus anciens
I need help, I don't know why this error occurred. Someone can explain me what I'm doing wrong and how can I solve it, please.
function dYfuncvecdz = ODEfun(z,Yfuncvec)
X= Yfuncvec(1);
% Explicit equations
cao = 8;
k = .01;
z = 200 - lam;
lam = 200 - z;
ca = cao*(1-X);
E1 = 4.44658e-10*lam^4-1.1802e-7*lam^3+1.35358e-5*lam^2-.000865652*lam+.028004;
E2 = -2.64e-9*lam^3+1.3618e-6*lam^2-.00024069*lam+.015011;
F1 = 4.44658e-10/5*lam^5-1.1802e-7/4*lam^4+1.35358e-5/3*lam^3-.000865652/2*lam^2+.028004*lam;
F2 = -(-9.30769e-8*lam^3+5.02846e-5*lam^2-.00941*lam+.618231-1);
ra = -k*ca^2;
if lam<=70
E=E1;
F=F1;
else
E=E2;
F=F2;
end
EF=E/(1-F);
% Differential equations
dXdz = -(ra/cao+EF*X);
dYfuncvecdz=[dXdz];
clc
zspan = [0 200]; % Range for the independent variable
y0 = [0]; % Initial values for the dependent variables
[t,y] = ode45(@ODEfun,tspan,y0);
z=size(y);
X=round(y(z(1,1),1),2);
a=['Conversion, X, predicted by Maximum Mixedness Model is ', num2str(X)];
disp(a)
plot(t,y,'LineWidth',1)
xlabel('time(mins)')
ylabel('X_m_m')
legend('X_m_m','Location','NorthWest')
title('Plot of conversion vs time predicted by Maximum Mixedness Model')
axis([0 200 0 1])
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Programmatic Model Editing dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!%2019.11.12.png)
