Polar Label Type Contour

1 次查看(过去 30 天)
Alexi
Alexi 2023-1-8
回答: ag 2024-10-2
I have 3 types of data. The first data is the angle, the second data is the radial distance, the third data is the pre-calculated data as a function of the first two data.
precomputed data
angle=[a1;a2;a3...];
radial =[r1;r2;r3..];
value=[var1;var2;var3...];
I tried this but ı didnt good result i think i'm wrong: The z values ​​must be a value in the x and y coordinates, not a function of x and y.
for example
angle = [0 36 72 108 144 180 216 252 288 324 360];
radial = [0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1];
value=[0.1;0.2;...........];
[a,r] = meshgrid(angle,radial);
[x,y] = pol2cart(a,r);
value = [var1;var2;var3...];; %must be located in x y coordinates
contourf(X,Y,Z,'ShowText','on')
daspect([1 1 1])
How can I obtain the circular contour distribution that indicates the position of the data calculated with the angle and distance data according to the angle and radial distance and writes (for example c label type) the value as a number?
I am sharing the similar graph that I want to achieve in the attachment.

回答(1 个)

ag
ag 2024-10-2
Hi Alexi,
To create a circular contour plot using your angle, radial distance, and precomputed values, you will need to map your data onto a grid in Cartesian coordinates, then use the "contourf" function to visualize it.
The below code snippet shows how to achieve this using dummy data:
angle = [0 36 72 108 144 180 216 252 288 324 360];
radial = [0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1];
value = rand(length(radial), length(angle));
% Create a meshgrid
[a, r] = meshgrid(deg2rad(angle), radial);
% Convert polar coordinates to Cartesian coordinates
[x, y] = pol2cart(a, r);
% Plot using contourf
figure;
contourf(x, y, value, 'ShowText', 'on');
colorbar;
title('Circular Contour Plot');
xlabel('X');
ylabel('Y');
For more details, please refer to the following MathWorks documentations:
Hope this helps!

类别

Help CenterFile Exchange 中查找有关 Contour Plots 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by