MATLAB简单点图

皮特

在while循环中,我需要绘制两个实体的位置(x,y)。也就是说,我要做的就是生成一个包含两个点的图。我需要将绘图缩放到特定的最大x和y值。另一个要求是以下事实:其中一个点需要围绕它放置三个同心环,每个同心环具有给定的半径。另外,这一切都将在一个循环中发生,因此我希望只打开一个绘图窗口,而不会让整个窗口都打开(每次循环迭代一个)。

基本上,这是我正在尝试(并且失败!)的伪代码:

-> Open new plot window, with a given x and y axis
while (running) {
  -> Clear the plot, so figure is nice and clean
  -> Plot the two points
  -> Plot the three circles around point A
}

我在MATLAB的文档中找到了几项,但是似乎没有一个绘图功能可以满足我的要求,或者在某些情况下,我无意中仅使用某些数据创建了多个绘图(即,一个绘图具有点,而另一个则具有圆) 。

蓝色

这是您可以在while循环中使用的示例代码

x0=1; y0=4; 
x1=2; y1=3;  % the x-y points
r=[1 2 3]; % 3 radii of concentrating rings
ang=0:0.01:2*pi; 
xc=cos(ang)'*r;
yc=sin(ang)'*r;

plot(x0,y0,'.',x1,y1,'.'); % plot the point A
hold on
plot(x1+xc,y1+yc); % plot the 3 circles

% set the limits of the plots (though Matlab does it for you already)
xlim([min([x0 x1])-max(r) max([x0 x1])+max(r)]);
ylim([min([y0 y1])-max(r) max([y0 y1])+max(r)]);

hold off

您可以非常轻松地使此工作循环进行,请阅读matlab的文档以了解如何执行此操作。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章