>> N=320;
dx=0.01;
a=4;
dt=0.0005;
c=300*dt/dx/dx;
u(1:100,1)=0;
x=linspace(0,1,100)';
u(2:50,1)=0.06/50*(2:50)';
u(50:99,1)=0.06/50.*(100-(50:99)');
u(2:99,2)=u(2:99,1)+c/2*(u(3:100,1)-2*u(2:99,1)+u(1:98,1))+...
c/2*a*dx*(u(3:100,1)-u(2:99,1));
plot([0,1],[0,0],'r')
hold on
h=plot(x,u(:,1),'linewidth',3);
set(h,'erasemode','xor');
axis([0,1,-0.1,0.1 ]);
for k=2:N
set(h,'XData',x,'YData',u(:,2));
drawnow;
u(2:99,3)=2*u(2:99,2)-u(2:99,1)+c*(u(3:100,2)...-2*u(2:99,2)+u(1:98,2));
u(2:99,3)=u(2:99,3) +c*a*dx*(u(3:100,2) -u(2:99,2));
u(:,1)=u(:,2);
u(:,2)=u(:,3);
pause(0.1)
end
运行之后出现了
??? u(2:99,3)=u(2:99,3) +c*a*dx*(u(3:100,2) -u(2:99,2));
|
Error: Unexpected MATLAB expression.
请高手指点!