用matlab怎么画圆

2025-03-03 20:42:37
推荐回答(3个)
回答1:

syms a b;
ezplot(  (2-a).^2+(50-b).^2 );

为什么这样画只能出现一个点?不能出现一个圆

答:这时圆没有半径, r=0;


syms a b;
ezplot(  (2-a).^2+(50-b).^2-1 );
解答:(Matlab R2013b)

>> syms a b
>> h=ezplot((2-a)^2+(50-b)^2==1,[1,3,49,51]);axis equal;
>> set(h,'color','r');
>> set(h,'linewidth',2);

参考资料:

>>help sym/ezplot

找Examples:

      syms x y t
      ezplot(cos(x))
      ezplot(cos(x), [0, pi])
      ezplot(x^2 - y^2 == 1)
      ezplot(x^2 + y^2 == 1,[-1.25,1.25],3); axis equal
      ezplot(1/y-log(y)+log(-1+y)+x == 1)
      ezplot(x^3 + y^3 - 5*x*y == 1/5,[-3,3])
      ezplot(x^3 + 2*x^2 - 3*x + 5 == y^2)
      ezplot(sin(t),cos(t))
      ezplot(sin(3*t)*cos(t),sin(3*t)*sin(t),[0,pi])

回答2:

%(x0,y0)为圆心,r为半径
%方法一
x0=5;
y0=10;
r=3;
theta=0:pi/50:2*pi;
x=x0+r*cos(theta);
y=y0+r*sin(theta);
plot(x,y,'-',x0,y0,'.');
axis square;

%方法二
rectangle('Position',[5-3,10-3,2*3,2*3],'Curvature',[1,1]);
axis square;

回答3:

xx = 3;yy = 5;
r = 2;
rectangle('Position',[xx-r,yy-r,2*r,2*r],'Curvature', [1 1]);

圆心就在(3,5)
把完整的程序发上来看一下吧