matlab - 如何在 MATLAB 中合并多个粘圆的结果

标签 matlab plot geometry

我尝试使用 viscircles 在函数中绘制一个圆,然后稍后返回该函数绘制另一个圆,如下图所示:

Multiple circles

目前,我只能使用这些代码行绘制单个圆圈:

figure
center = [numberX numberY];
xlim([-0.1 10.1])
ylim([-0.1 10.1])
axis square
artwork = viscircles(center,size,'Color',colorControl)

绘制第一个viscircles后,控制回滚到提示函数以获取下一个viscircles的数据,但是当它返回到绘图时,原始的即使我尝试使用 hold onviscircles 也会被覆盖。任何建议将不胜感激。

最佳答案

viscircles默认情况下,将刷新图形并仅绘制由您提供的输入指定的圆圈,因此 hold on 将不起作用。

您可以做的就是继续附加数据,以便每次提示输入新数据时都会显示原始数据,后跟一个新圆圈。

因此,做这样的事情。假设您有一个名为 getNewCenter 的函数,它返回一个新的中心、圆的大小和颜色,以及包含要显示的中心及其大小的矩阵:

centers = [];
sizes = []; % Matrices that contain the centers and sizes

while true % Keep iterating...

    [numberX, numberY, size, colorControl] = getNewCenter; % Get new center, size and colour

    % Add to the data
    centers = [centers; numberX numberY];
    sizes = [sizes; size];

    % Plot the circles
    xlim([-0.1 10.1]);
    ylim([-0.1 10.1]);
    axis square;
    artwork = viscircles(centers, sizes, 'Color', colorControl);
end

关于matlab - 如何在 MATLAB 中合并多个粘圆的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40756053/

相关文章:

matlab - 行的随机顺序 Matlab

python - 将不同的 seaborn 面网格组合成单个图

python - python 中 3D 多边形的交点

c# - 两组中最接近的一对点,每组一个

javascript - 从点创建多边形的算法

MATLAB:提取与最大 y 值匹配的 x 坐标

Matlab - 三角函数的乘积简化

arrays - MATLAB迭代添加数组元素: time behavior

python - 更改seabornpairplot对角线颜色

r - 如何自动绘制具有相同行数和列数的多个 CSV 文件?