matlab中如何保存运行程序时出现的动画?n=100;m=3;v=2;x=0;u=3*v*[sech(sqrt(v).*(x)./v)].^2;h=plot(x,u);axis([-10 10 -2 10])set(h,'EraseMode','Xor' );for l=1:mfor k=-300:nx=-10:0.01:20;t=k/n;u=3*v*[sech(sqrt(v).*(x-v.*t)./v)].^2;set(h,'XDa
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/25 09:14:04
matlab中如何保存运行程序时出现的动画?n=100;m=3;v=2;x=0;u=3*v*[sech(sqrt(v).*(x)./v)].^2;h=plot(x,u);axis([-10 10 -2 10])set(h,'EraseMode','Xor' );for l=1:mfor k=-300:nx=-10:0.01:20;t=k/n;u=3*v*[sech(sqrt(v).*(x-v.*t)./v)].^2;set(h,'XDa
matlab中如何保存运行程序时出现的动画?
n=100;
m=3;
v=2;
x=0;
u=3*v*[sech(sqrt(v).*(x)./v)].^2;
h=plot(x,u);
axis([-10 10 -2 10])
set(h,'EraseMode','Xor' );
for l=1:m
for k=-300:n
x=-10:0.01:20;
t=k/n;
u=3*v*[sech(sqrt(v).*(x-v.*t)./v)].^2;
set(h,'XData',x,'YData',u);
pause(0.01)
%drawnow
end
l=l+1;
end
matlab中如何保存运行程序时出现的动画?n=100;m=3;v=2;x=0;u=3*v*[sech(sqrt(v).*(x)./v)].^2;h=plot(x,u);axis([-10 10 -2 10])set(h,'EraseMode','Xor' );for l=1:mfor k=-300:nx=-10:0.01:20;t=k/n;u=3*v*[sech(sqrt(v).*(x-v.*t)./v)].^2;set(h,'XDa
n=100;
m=3;
v=2;
x=0;
u=3*v*[sech(sqrt(v).*(x)./v)].^2;
figure(1);
h=plot(x,u);
axis([-10 10 -2 10])
set(h,'EraseMode','Xor' );
F = getframe(1);
im = frame2im(F);
[X,map] = rgb2ind(im,256);
imwrite(X,map,'filename','gif','Loopcount',inf,'Delaytime',0);
for l=1:m
for k=-300:n
x=-10:0.01:20;
t=k/n;
u=3*v*[sech(sqrt(v).*(x-v.*t)./v)].^2;
set(h,'XData',x,'YData',u);
%pause(0.01)
drawnow
F = getframe(1);
im = frame2im(F);
[X,map] = rgb2ind(im,256);
imwrite(X,map,'filename','gif','WriteMode','append','Delaytime',0);
end
l=l+1;
end
输出的图片是filename.gif