Help with polar contour plots

6 次查看(过去 30 天)
I am trying to plot the variable MW_FINAL in filled polar contour plot. The plot must look like the attached image. Below is the code I used to find MW_FINAL. The reqired data files are also attached.
close all;clear all;clc
format short g
wazim = 0:4:360;
wincli = 0:1:90;
mw_without_pw = importdata('MW WITHOUT POW.mat');
mw_on_pw = importdata('MW WITh POW amadei solution.mat');
for i = 1:length(wazim)
for j = 1:length(wincli)
if mw_without_pw(j,i) > mw_on_pw(j,i)
MW_FINAL(j,i) = mw_without_pw(j,i);
else
MW_FINAL(j,i) = mw_on_pw(j,i);
end
end
end

回答(1 个)

Divyajyoti Nayak
Divyajyoti Nayak 2024-10-17
MATLAB does not have any direct way to create filled polar contour plots but from MATLAB R2024a, the "polarregion" function can be used as a workaround to programmatically create such plots. Do note that this approach is very graphically intensive. Here’s a documentation link to the "polarregion" function:
Here's the code I wrote for making the required plot:
close all;clear;clc
format short g
wazim = 0:4:360;
wincli = 0:1:90;
thetas = zeros(91);
radii = zeros(91);
mw_without_pw = importdata('MW WITHOUT POW.mat');
mw_on_pw = importdata('MW WITh POW amadei solution.mat');
for i = 1:length(wazim)
for j = 1:length(wincli)
if mw_without_pw(j,i) > mw_on_pw(j,i)
MW_FINAL(j,i) = mw_without_pw(j,i);
else
MW_FINAL(j,i) = mw_on_pw(j,i);
end
thetas(j,i) = wazim(i);
radii(j,i) = wincli(j);
end
end
n = numel(MW_FINAL);
cmap = turbo(n); %Creating a color map for data
%Mapping the data with the color map
cDataMap = (MW_FINAL - min(MW_FINAL,[], 'all'))/(max(MW_FINAL,[],'all')-min(MW_FINAL,[],'all')) * (n-1) + 1;
%Reshaping all data required for polarregion function
cDataMap = reshape(cDataMap,[8281,1]);
thetas = reshape(thetas,[8281,1]);
radii = reshape(radii,[8281,1]);
%Getting RGB values from color map using the mapped data
colorData = cmap(floor(cDataMap),:);
%Creating individual polar grid areas of the filled polar contour plot
pr = polarregion([(thetas-2),(thetas+2)]*pi/180,[(radii-0.5),(radii+0.5)]*pi/180,'FaceAlpha',1);
%Changing the color of each polarregion according to the color data
for i = 1:length(pr)
pr(i).FaceColor = colorData(i,:);
end
And here's the result:

类别

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

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by