error: Unrecognized function or variable 'y', using ode45

10 vues (au cours des 30 derniers jours)
Fernanda Vargas
Fernanda Vargas le 24 Fév 2021
this is my code and i get error: Unrecognized function or variable 'y', please help
function main
a = 0.01725*exp(2660/300);
E = 2660;
T0 = 300;
Cao = 2;
cpa = 20;
cpb = 20;
nao = 2*1200;
nbo = 2*1200;
b = (10*nao)/(cpa*nao+cpb*nbo);
[t,y]=ode45(@(t,y) DiabaticBatch(a,E,T0,Cao,b),[0 4000],[0 0]);
end
function dydt = DiabaticBatch(a,E,T0,Cao,b)
dydt = zeros(2,1);
dydt(1) = a*exp(-E/(T0+y(2)*b))*Cao*(1-y(1))^2;
dydt(2) = b*dydt(1);
end

Réponse acceptée

Walter Roberson
Walter Roberson le 24 Fév 2021
function main
a = 0.01725*exp(2660/300);
E = 2660;
T0 = 300;
Cao = 2;
cpa = 20;
cpb = 20;
nao = 2*1200;
nbo = 2*1200;
b = (10*nao)/(cpa*nao+cpb*nbo);
[t,y]=ode45(@(t,y) DiabaticBatch(t,y,a,E,T0,Cao,b),[0 4000],[0 0]);
end
function dydt = DiabaticBatch(t,y,a,E,T0,Cao,b)
dydt = zeros(2,1);
dydt(1) = a*exp(-E/(T0+y(2)*b))*Cao*(1-y(1))^2;
dydt(2) = b*dydt(1);
end

Plus de réponses (0)

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by