MATLAB解微分方程
Uc=0.9292;Ac=3.8513e-004;
Tc=0.8237;
Cc=0.9843;
y0=0.9486;
f=inline('Tc*(-y+Cc*((Uc-Ac/(y.^2)).^0.5)','Tc','Cc','Uc','Ac','x','y');%微分方程的右边项
dx=0.004; %x方向步长
xleft=0.029000; %区域的左边界
xright=1.020991; %区域的右边界
xx=xleft:dx:xright; %一系列离散的点
n=length(xx); %点的个数
%%(2)龙格--库塔法
RK=y0;
for i=2:n
k1=f(Tc,Cc,Uc,Ac,xx(i-1),RK(i-1));
k2=f(Tc,Cc,Uc,Ac,xx(i-1)+dx/2,RK(i-1)+k1*dx/2);
k3=f(Tc,Cc,Uc,Ac,xx(i-1)+dx/2,RK(i-1)+k2*dx/2);
k4=f(Tc,Cc,Uc,Ac,xx(i-1)+dx,RK(i-1)+k3*dx);
RK(i)=RK(i-1)+dx*(k1+2*k2+2*k3+k4)/6;
end
运行后老是提示错误为
??? Error using ==> inlineeval
Error in inline expression ==> Tc*(-y+Cc*((Uc-Ac/(y.^2)).^0.5)
??? Error: Incomplete or misformed expression or statement.
Error in ==> inline.subsref at 25
INLINE_OUT_ = inlineeval(INLINE_INPUTS_, INLINE_OBJ_.inputExpr, INLINE_OBJ_.expr);
Error in ==> gyddj2 at 69
k1=f(Tc,Cc,Uc,Ac,xx(i-1),RK(i-1));
请高手指点,谢谢!