2014-11-02 282 views
7

我被要求找到不同的方式在MATLAB中绘制圆圈,在MATLAB中绘制圆圈

看起来很无聊。不过,我能想出一些想法(有些人可能是低效的!),

方法1

ezpolar(@(x)1); 

方法2

t = linspace(0,2*pi,100); 
plot(sin(t),cos(t)); 

方法3

[X,Y,~] = cylinder(1,100); 
plot(X(1,:),Y(1,:)); 

方法4

ezplot('x^2 + y^2 - 1'); 

方法5

theta = linspace(0,2*pi,100); 
ro = ones(1,100); 
[X,Y] = pol2cart(theta,ro); 
plot(X,Y); 

,并得到了有趣。

我很好奇,如果你有其他的想法。

谢谢。

Edit

方法11

azimuth = linspace(-pi,pi,100); 
r = ones(1,100); 
elevation = zeros(1,100); 
[X,Y,Z] = sph2cart(azimuth,elevation,r); 
patch(X,Y,Z) 
%% (not sure how it works! any improvement suggestions?) 

回答

4

如果你打算去极坐标,再有就是还

方法6

theta = linspace(0,2*pi,100); 
rho = ones(1,100); 
polar(theta, rho) 

方法7

ezpolar('1') % Shortest? 


您也可以利用复数和how they're handled通过plot

方法8

theta = linspace(0,2*pi,100); 
rho = ones(1,100); 
z = rho.*exp(1i*theta); 
plot(z) 

以上可以上一个完成线。它也可以被绘制成:

plot(real(z),imag(z)) 

方法9

plot(0,0,'o','MarkerSize',100) 

方法10

text(0,0,'\circ','FontSize',200) 

许多other unicodecharacters可用于生产圆。


你可以与微分方程,例如,circular orbits和圆形limit cycles(霍普夫振荡器)扩展,以产生圆。

2

方法12

rectangle('Position', [-0.5, -0.5, 1, 1], 'Curvature', [1 1]); 

广义:

circle = @(x, y, r) rectangle('Position', [x-r, y-r, 2*r, 2*r], ... 
    'Curvature', [1 1]); 

circle(0, 0, 1); 
circle(10, 20, 5); 
axis equal; 
+0

感谢您的回答, – Rashid 2016-06-24 09:20:23