matlab code solves the system of differential equations but it plots the initial values,not the answer.help!!please!!
1 次查看(过去 30 天)
显示 更早的评论
hi everyone!i have this code and it runs but there is a problem,it keeps the initial values instead of solving the differential equations can you help? :)
function my_ode
[T,F]=ode15s(@diff2,[0 5],[10 20 0 333]);
plot(T,F(:,1),'-',T,F(:,2),'.',T,F(:,3),'*',T,F(:,4),'^')
end
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))/(f(1)*cpa+f(3)*cpb+f(2)*cpw);
end
1 个评论
Geoff Hayes
2015-10-31
Maroubi - please clarify what the problem is. In your question title you state ...it plots the initial values,not the answer and in your question body you state ...it keeps the initial values instead of solving the differential equations. Have you stepped through the code to verify that T and F are correct? It does seem that (over time) the problem converges to a solution.
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!