Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
![]() |
#1 |
高级会员
注册日期: 2019-11-21
帖子: 3,006
声望力: 66 ![]() |
![]()
在循环内进行绘图时,如何精确地在Matlab绘图中获得固定的轴缩放比例?我的目的是看数据如何在循环内演化。我尝试使用运气好的axis manual和axis(...) 。有什么建议么?
我知道hold on这个问题,但是我不想看到旧数据。 回答: 如果要查看新的绘制数据替换旧的绘制数据,但保持相同的轴限制,则可以在循环中使用SET命令来更新绘制数据的x和y值。这是一个简单的例子: hAxes = axes; %# Create a set of axes hData = plot(hAxes,nan,nan,'*'); %# Initialize a plot object (NaN values will %# keep it from being displayed for now) axis(hAxes,[0 2 0 4]); %# Fix your axes limits, with x going from 0 %# to 2 and y going from 0 to 4 for iLoop = 1:200 %# Loop 100 times set(hData,'XData',2*rand,... %# Set the XData and YData of your plot object 'YData',4*rand); %# to random values in the axes range drawnow %# Force the graphics to update end 当您执行上述操作时,您会看到星号在轴中跳跃了几秒钟,但是轴限制将保持不变。您不必使用HOLD命令,因为您只是在更新现有的绘图对象,而无需添加新的对象。即使新数据超出轴限制,限制也不会改变。 更多&回答... |
![]() |
![]() |