MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   Matlab轴缩放 (https://www.labfans.com/bbs/showthread.php?t=24078)

poster 2019-12-10 20:48

Matlab轴缩放
 
在循环内进行绘图时,如何精确地在Matlab绘图中获得固定的轴缩放比例?我的目的是看数据如何在循环内演化。我尝试使用运气好的axis manual和axis(...) 。有什么建议么?

我知道hold on这个问题,但是我不想看到旧数据。



[B]回答:[/B]

如果要查看新的绘制数据替换旧的绘制数据,但保持相同的轴限制,则可以在循环中使用[URL="http://www.mathworks.com/help/techdoc/ref/set.html"]SET[/URL]命令来更新绘制数据的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 当您执行上述操作时,您会看到星号在轴中跳跃了几秒钟,但是轴限制将保持不变。您不必使用[URL="http://www.mathworks.com/help/techdoc/ref/hold.html"]HOLD[/URL]命令,因为您只是在更新现有的绘图对象,而无需添加新的对象。即使新数据超出轴限制,限制也不会改变。



[url=https://stackoverflow.com/questions/4086452]更多&回答...[/url]


所有时间均为北京时间。现在的时间是 09:45

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.