contour plot in polar coordinates
2 次查看(过去 30 天)
显示 更早的评论
Hi
Found this code for generating contour plots with polar coordinates. It works, but I don't understand why and I also need to plot contour plots with polar coordinates. Can someone, please, explain the code to me?
Thanks
Shani
++++++++++THE CODE-----------------
% Create polar data
[r,t] = meshgrid(0:.1:5,0:pi/30:(2*pi));
z = r - t;
% Convert to Cartesian
x = r.*cos(t);
y = r.*sin(t);
h = polar(x,y);
hold on;
contourf(x,y,z);
% Hide the POLAR function data and leave annotations
set(h,'Visible','off')
% Turn off axes and set square aspect ratio
axis off
axis image
2 个评论
回答(1 个)
Kye Taylor
2012-3-29
It may be helpful to know that the line of code
z = r-t
defines the surface as a function of r and t. For example, if you just wanted to look at the function z(r) = r*cos(t), which is equivalent to the function f(x,y) = x in cartesian coordinates, change
z = r - t;
to
z = r.*cos(t);
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Polar Plots 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!