How to plot six concentric circles using meshgrid and plot?
7 次查看(过去 30 天)
显示 更早的评论
I am trying to plot six concentric circles using meshgrid() and plot(). The circles' radii vary between 0.5 and 1.75 (with intervals of 0.25). I am wondering whether the code below is sufficiently efficient and whether indeed it should be performed as delineated below:
theta = linspace(0, 2*pi, 50);
[X, Y] = meshgrid(0.5:0.25:1.75, theta);
plot(a+cos(Y).*X, b+sin(Y).*X);
?
采纳的回答
Matt J
2013-3-27
You could conserve a little memory if you did it this way, but I don't know anyone who cares about efficiency for such a small plotting task,
theta = linspace(0, 2*pi, 50).';
R=0.5:0.25:1.75;
plot(a+cos(theta)*R, b+sin(theta)*R);
8 个评论
Matt J
2013-3-27
编辑:Matt J
2013-3-27
Yes, the transposition of theta was only relevant to my proposed approach -- the one that does not use meshgrid. Notice that you use elementwise .* multiplication whereas I use pure matrix multiplication '*'. Matrix multiplication requires the operands to be appropriately shaped.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!