Plot contour for polar coordinate

31 ビュー (過去 30 日間)
Djamel HAMMOUDI
Djamel HAMMOUDI 2018 年 9 月 1 日
回答済み: Jacob Mathew 2024 年 12 月 5 日
Hello; How to plot contours for polar coordinate. I have The pressure distribution for angle theta and R. Thank you.

回答 (1 件)

Jacob Mathew
Jacob Mathew 2024 年 12 月 5 日
Hi Djamel,
You can use meshgrid and contourf functions in tandem to plot a contour with polar coordinates. The following example demonstrates it:
% Define Z axis
Z = @(r, theta) cos(r) .* sin(theta);
% Define the grid in polar coordinates
r = linspace(0, 3, 100); % Radius
theta = linspace(0, 2*pi, 100); % Angle
% Create a meshgrid
[R, Theta] = meshgrid(r, theta);
% Compute Z values
Z_values = Z(R, Theta);
% Convert polar to Cartesian coordinates
X = R .* cos(Theta);
Y = R .* sin(Theta);
% Create the contour plot
figure;
contourf(X, Y, Z_values, 'LineStyle', 'none');
colorbar;
title('Contour Plot in Polar Coordinates');
xlabel('X');
ylabel('Y');
axis equal;
You can refer to the documentation for meshgrid and contourf functions below:

カテゴリ

Help Center および File ExchangeContour Plots についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by