this is my fynction.it says Error using my_ode (line 18) Not enough input arguments. can you help?
function df=diff2(t,f)
Tc=60+5*(60-25)
nw=20
k0=5e10
x=15000
c=-9020
pa=14.384
pw=55.382
pb=13.668
cpa=125
cpw=75
cpb=250
a=-55570
b=-349700
df(1)=-f(6)*f(1);
df(2)=0;
df(3)=-df(1);
df(4)=(x*(Tc-f(4))-df(1)*a-df(3)*b-(df(1)*cpa+df(3)*cpb+df(2)*cpw)*f(4))/(na*cpa+nb*cpb+nw*cpw);
f(5)=(na/pa)+(nb/pb)+(nw/pw);
f(6)=k0*exp(c/f(4));
end
function my_ode()
[T,F]=ode45(@diff2,[0 100],[10 20 0 333 1.056 8.6e-2])
plot(T,F(:,1),'-',T,F(:,2),'-',T,F(:,3),'-',T,F(:,4),'-',T,F(:,5),'-',T,F(:,6),'-')
end

 Réponse acceptée

Torsten
Torsten le 30 Oct 2015

0 votes

function my_ode
[T,F]=ode15s(@diff2,[0 100],[10 20 0 333]);
plot(T,F(:,1),'-',T,F(:,2),'-',T,F(:,3),'-',T,F(:,4),'-')
function df=diff2(t,f)
Tc=60+5*(60-25);
nw=20;
k0=5e10;
x=15000;
c=-9020;
pa=14.384;
pw=55.382;
pb=13.668;
cpa=125;
cpw=75;
cpb=250;
a=-55570;
b=-349700;
df=zeros(4,1);
df(1)=-k0*exp(c/f(4))*f(1);
df(2)=0;
df(3)=-df(1);
df(4)=(x*(Tc-f(4))-df(1)*a-df(3)*b-(df(1)*cpa+df(3)*cpb+df(2)*cpw)*f(4))/(na*cpa+nb*cpb+nw*cpw);
Best wishes
Torsten.

5 commentaires

maroubi maria
maroubi maria le 30 Oct 2015
you are the best!!!!!
maroubi maria
maroubi maria le 30 Oct 2015
thank you a lot
maroubi maria
maroubi maria le 30 Oct 2015
we still have a problem because it is plotting the df(1),df(2),df(3) ntc and not the f(1),f(2),f(3) ntc that we need. did we write wrong the equations or the code is wrong? thank you
Torsten
Torsten le 30 Oct 2015
As written, MATLAB plots f(1),...,f(4) over T.
You can easily check this:
The first plot should start at 10, the second at 20, the third at 0 and the fourth at 333.
Best wishes
Torsten.
maroubi maria
maroubi maria le 30 Oct 2015
actually the problem is that it keeps the initial values

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Programming dans Centre d'aide 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