Matlab:用固定轴绘制动画
当我调用此函数时,轴随绘图移动。我怎样才能阻止这种事情发生?我尝试将Matlab:用固定轴绘制动画,matlab,plot,Matlab,Plot,当我调用此函数时,轴随绘图移动。我怎样才能阻止这种事情发生?我尝试将xlim和ylim放在命令窗口中的函数之前,但没有成功 我的代码是: function h = plootwithanimation(x,y) for h = 1:length(x) plot(x(h),y(h),'*') pause(1) hold on end 尝试使用轴功能: function h = plootwithanimation(x,y)
xlim
和ylim
放在命令窗口中的函数之前,但没有成功
我的代码是:
function h = plootwithanimation(x,y)
for h = 1:length(x)
plot(x(h),y(h),'*')
pause(1)
hold on
end
尝试使用轴
功能:
function h = plootwithanimation(x,y)
for h = 1:length(x)
plot(x(h),y(h),'*')
axis([0 10 -2 100]) %or whatever you want. This sets 0<x<10 and -2<y<100
pause(1)
hold on
end
函数h=plootwithanimation(x,y)
对于h=1:长度(x)
图(x(h),y(h),“*”)
轴([0 10-2 100])%或任何您想要的。这将设置为0您可以在尝试时使用和来修复边界,但是在调用plot
之前,plotting将忽略您设置轴的任何内容
您应该在绘图后使用它们
function h = plotwithanimation(x, y, xlims, ylims)
% Also pass in axis limits
% xlims = [x0,x1]
% ylims = [y0,y1]
hold on; % You only have to hold on once around plotting
for h = 1:length(x)
plot(x(h),y(h),'*');
xlim(xlims);
ylim(ylims);
pause(1);
end
hold off; % Good habit so you don't accidentally plot over this figure later