在MATLAB中绘制圆 [英] Plot Circle in MATLAB
问题描述
我被要求找到不同的方法在MATLAB中绘制一个圆圈,
看起来很无聊。但是我可以想出一些想法(有些可能效率不高!),
方法1
ezpolar(@(x)1);
方法2
t = linspace(0,2 * pi,100);
plot(sin(t),cos(t));
方法3
[X,Y,〜] =圆柱体(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);
它很有趣。
I我很好奇,如果你有其他想法。
谢谢。
编辑
方法11
azimuth = linspace(-pi,pi,100);
r = ones(1,100);
标高=零(1,100);
[X,Y,Z] = sph2cart(azimuth,elevation,r);
补丁(X,Y,Z)
%%(不知道它是如何工作的!任何改进建议?)
如果你打算去极坐标,那么也有
方法6
theta = linspace(0,2 * pi,100);
rho = ones(1,100);
polar(theta,rho)
方法7 p>
ezpolar('1')%最短?
您也可以利用复数和它们的处理方式 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 )
您可以将其扩展为用微分方程生成圆圈,例如圆形轨道和圆形限制周期(Hopf振荡器)。
I was asked to find different ways to plot a circle in MATLAB,
It seems boring. However I could come up with some ideas (some might be inefficient!),
Method 1
ezpolar(@(x)1);
Method 2
t = linspace(0,2*pi,100);
plot(sin(t),cos(t));
Method 3
[X,Y,~] = cylinder(1,100);
plot(X(1,:),Y(1,:));
Method 4
ezplot('x^2 + y^2 - 1');
Method 5
theta = linspace(0,2*pi,100);
ro = ones(1,100);
[X,Y] = pol2cart(theta,ro);
plot(X,Y);
and it got interesting.
I'm curious if you have other ideas.
Thanks.
Edit
Method 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?)
If you're going to go to polar coordinates, then there's also
Method 6
theta = linspace(0,2*pi,100);
rho = ones(1,100);
polar(theta, rho)
Method 7
ezpolar('1') % Shortest?
You can also take advantage complex number and how they're handled by plot
:
Method 8
theta = linspace(0,2*pi,100);
rho = ones(1,100);
z = rho.*exp(1i*theta);
plot(z)
The above could be done on one line. It could also be plotted as:
plot(real(z),imag(z))
Method 9
plot(0,0,'o','MarkerSize',100)
Method 10
text(0,0,'\circ','FontSize',200)
Many other unicode characters can be used to produce circles.
You could extend this to generating circles with differential equations, e.g., circular orbits and circular limit cycles (Hopf oscillator).
这篇关于在MATLAB中绘制圆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!