无法在matlab中使用ezplot绘制圆圈

问题描述 投票:0回答:1

我想在图MATLAB中绘制6个圆圈。但它不会出现。

我已经想到这个代码是正确的,我试着给出轴限制。但它无法解决我的问题。

clear all;
clc;
p=[8 9 3 4 7 4];
rtopi=[3 4 16 25 34 25];
n=length(p);
for ii=1:n
    f=@(x,y)(x-p(ii)).^2+(y).^2-rtopi(ii)^2;
    gambar=ezplot(f);
    set(gambar,'color','k','linewidth',2);
    grid on;
    axis equal;
    set(gca,'Color','y');
    xlabel('Real');
    ylabel('Imaginary');
    title('Discs');
    axis([-30 30 -30 30]);
end

这是结果:

enter image description here

怎么解决?

matlab plot matlab-figure
1个回答
2
投票

删除函数定义中的。*,只使用x ^ 2而不是x。^ 2。

在循环结束前使用'hold on'

在循环外移动背景颜色,网格,标题等。

最重要的是,为ezplot声明xmin,xmax。默认值为(-2pi到2pi)。尝试:gambar = ezplot(f,[xmin,xmax})并使用xmin和xmax的绘图限制

© www.soinside.com 2019 - 2024. All rights reserved.