Help with polar contour plots

조회 수: 8 (최근 30일)
erhamah alsuwaidi
erhamah alsuwaidi 2019년 2월 14일
답변: Divyajyoti Nayak 2024년 10월 17일
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