2014-11-02 334 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