www.gusucode.com > graphics 案例源码程序 matlab代码 > graphics/ContourPlotPolarCoordinatesExample.m
%% Contour Plot in Polar Coordinates % This example shows how to create a contour plot for data defined in a % polar coordinate system. % %% Display Surface to Contour % Set up a grid in polar coordinates and convert the coordinates to % Cartesian coordinates. % Copyright 2015 The MathWorks, Inc. th = (0:5:360)*pi/180; r = 0:.05:1; [TH,R] = meshgrid(th,r); [X,Y] = pol2cart(TH,R); %% % Generate the complex matrix |Z| on the interior of the unit circle. Z = X + 1i*Y; %% % Display a surface of the mathematical function $\sqrt[-4]{z^4-1}$. Use % the |summer| colormap. f = (Z.^4-1).^(1/4); figure surf(X,Y,abs(f)) colormap summer %% % Display the unit circle beneath the surface and add labels to the graph. hold on surf(X,Y,zeros(size(X))) hold off xlabel('Real') ylabel('Imaginary') zlabel('abs(f)') %% Contour Plot in Cartesian Coordinates % Display a contour plot of the surface in Cartesian coordinates. figure contour(X,Y,abs(f),30) axis equal xlabel('Real') ylabel('Imaginary') %% Contour Plot in Polar Coordinates % Display a contour plot of the surface in a polar axes. Use the |polar| % function to create a polar axes, and then delete the line created with % |polar|. h = polar([0 2*pi], [0 1]); delete(h) %% % With |hold on|, display the contour plot on the polar grid. hold on contour(X,Y,abs(f),30)