软件编程版 #193941 层

求救:有没有MATLAB学得不错的高人

楼主 · 1 楼
我想解一个微分方程f(x)*f''(x)+cf(x)^2*f'(x)-2f(x)-1=0
(知道边界条件:f(x=无穷大)=0,f'(x=无穷大)=0,用数值方法把他的图形画出来,该怎末办?请求高人指点
我找到一个求竿的温度分布的例子(在附件中),试了一下却无法运行:
M=input('give the number of subintervals (M):');
deltax=1/M;
xx=0:deltax:1;
funcstr=input('Give f(x),the extra heat source (e.g.,x.^3);','s');
T0=input('Give y(0) (left):');
T1=input('Give y(1) (right):');
vectorOnes=ones(M-1,1);
A=spdiags([-vectorOnes,2*-vectorOnes,-vectorOnes],[-1 0 1],M-1,M-1);
x=xx(2:end-1);
f=eval(funcstr);
b=detax^2*f;
b(1)=b(1)+T0;
b(end)=b(end)+T1;
b=b';
Y=A/b';
Y=[T0;Y;T1];
cal;
subplot(2,1,1);
plot(x,f);
grid on;
title('externalheat f(x).',');
subplot(2,1,2);
plot(xx,y,'r');
grid on;
title('tem distribution f(x).',');
give the number of subintervals (M):
??? Error using ==> /
Matrix dimensions must agree.