How to patch the area under curve for a polarplot?

142 ビュー (過去 30 日間)
Ron
Ron 2025 年 8 月 13 日 5:07
コメント済み: Star Strider 2025 年 8 月 20 日 12:08
I want to create a figure as shown below using "polarplot" function. Can anyone please help me regarding this?
  3 件のコメント
Star Strider
Star Strider 2025 年 8 月 16 日 12:58
編集済み: Walter Roberson 2025 年 8 月 16 日 19:47
It would be best for you to Contact Support.
Include the URL of this thread in your note to MathWorks.
Please post their reply sonewhere in this thread. (Note that what you want may be proprietary information.)
Ron
Ron 2025 年 8 月 17 日 10:20
I completely agree with the last point of yours and in that case it is completely fine for them to not disclose it here. However I have been able to find and alternate way of getting my desired results and I have that it might be usefull for other. I am posting the code that I have written.

サインインしてコメントする。

回答 (3 件)

Chuguang Pan
Chuguang Pan 2025 年 8 月 13 日 6:44
  1 件のコメント
Ron
Ron 2025 年 8 月 13 日 7:04
Thank you so much for taking out time to reply but the answere says that this feature works for the version 2025a whereas I have 2023a.

サインインしてコメントする。


Ron
Ron 2025 年 8 月 17 日 10:21
移動済み: Star Strider 2025 年 8 月 20 日 12:04
clc; clear all;
h1 = helix(Radius=31e-3, Width=1.2e-3, Turns=4); %%% Input Data for pattern function
h2 = helix(Radius=26e-3, Width=1.2e-3, Turns=4);%%% Input Data for pattern function
H1 = pattern(h1,1.8e9,0,0:1:360); %%% Input Data for polarpattern function
H2 = pattern(h2,1.8e9,0,0:1:360); %%% Input Data for polarpattern function
% % Plot the polar pattern.
figure
P0 = polarpattern(H1,'AntennaMetrics',1,'FontName','Times New Roman'); hold on
P0 = polarpattern(H2);
%%%%%%%%%%%%%%%%%%%%% Finding the lobes
pp=findLobes(P0,1); %%% It is important to find the lobes to match their indices with those of XData/YData
pp1=fieldnames(pp);
XYmain=pp.mainLobe.extent
XYside=pp.sideLobes.extent;
XYback=pp.backLobe.extent;
aa0=P0.Parent.Parent.CurrentFigure.CurrentAxes.Children;
aa=(get(aa0,'Tag'));
for ii=1:length(aa)
PatchLen(ii,:)=convertCharsToStrings(aa{ii});
end
ind=contains(PatchLen,"Lobe");
[aa,bb]=find(ind==1);
%%%%%%%%%%%%%%%%%%%%% Finding the XData and YData corresponding to the patch
for nn=1:length(bb)
xx1{:,nn}=P0.Parent.Parent.CurrentFigure.CurrentAxes.Children(aa(nn)).XData(1:end-2);
yy1{:,nn}=P0.Parent.Parent.CurrentFigure.CurrentAxes.Children(aa(nn)).YData(1:end-2);
end
%%%%%%%%%%%%%%%%%%%%% Default patch sequence is Side left lobe, Side right lobe, Back lobe and Front lobe
%%%%%%%%%%%%%%%%%%%%% this is different from the sequence of the findLobes fucntion hence to match both of them do this
if length(bb)==4
xx1([1 2 3 4])=xx1([4 2 3 1]);yy1([1 2 3 4])=yy1([4 2 3 1]);
elseif length(bb)==3
xx1([1 2 3])=xx1([3 2 1]);yy1([1 2 3])=yy1([3 2 1]);
elseif length(bb)==2
xx1([1 2])=xx1([2 1]);yy1([1 2])=yy1([2 1]);
end
%%%%%%%%%%%%%%%%%%%%% Create single XData and YData matrices of points corresponding to the patches
xx3=[]; yy3=[];
for nn=1:length(bb)
xx3=vertcat(xx3,xx1{1,nn});
yy3=vertcat(yy3,yy1{1,nn});
end
%%%%%%%%%%%%%%%%%%%%% If you want to compare 2 patterns and use patches to show regions of x% relative erro then use this part
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Start
DataDiff=abs(((H1+100)-(H2+100))./(H1+100))*100;
figure
plot(H2,"--"); hold on
plot(H1);
plot(DataDiff);
ind=DataDiff<2; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Condition for error
DataDiffInd=diff([0;ind;0]);
beginsBlue=find(DataDiffInd==1);
endsBlue=find(DataDiffInd==-1)-1;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Ends
XDataPatch = circshift(xx3,XYmain(1)-1); %%%%%%%%% Match the patch coordinates with those of Lobes
YDataPatch = circshift(yy3,XYmain(1)-1); %%%%%%%%% Match the patch coordinates with those of Lobes
figure
P1 = polarpattern(H1',...
'FontName','Times New Roman',...
'FontSize',13); hold on
P1 = polarpattern(H2',...
'FontName','Times New Roman',...
'FontSize',13);
P1.MagnitudeAxisAngle=80;
P1.AngleResolution=30;
%%%%If you want custom patches then use this template
%% XDataPatchN1=[XDataPatch(start:end);0];
%% YDataPatchN1=[YDataPatch(start:end);0];
%% PatchyThings(XDataPatchN1,YDataPatchN1,"Blue");
n=length(beginsBlue);
for nn=1:n
if nn==1
XDataPatchN1=[XDataPatch(beginsBlue(nn):endsBlue(nn));0];
YDataPatchN1=[YDataPatch(beginsBlue(nn):endsBlue(nn));0];
PatchyThings(XDataPatchN1,YDataPatchN1,"Blue");
XDataPatchN1=[XDataPatch(endsBlue(nn):beginsBlue(nn+1));0];
YDataPatchN1=[YDataPatch(endsBlue(nn):beginsBlue(nn+1));0];
PatchyThings(XDataPatchN1,YDataPatchN1,"Red");
elseif 1<nn && nn<n
XDataPatchN1=[XDataPatch(beginsBlue(nn):endsBlue(nn));0];
YDataPatchN1=[YDataPatch(beginsBlue(nn):endsBlue(nn));0];
PatchyThings(XDataPatchN1,YDataPatchN1,"Blue");
XDataPatchN1=[XDataPatch(endsBlue(nn):beginsBlue(nn+1));0];
YDataPatchN1=[YDataPatch(endsBlue(nn):beginsBlue(nn+1));0];
PatchyThings(XDataPatchN1,YDataPatchN1,"Red");
else
if ismember(1,beginsBlue)
XDataPatchN1=[XDataPatch(beginsBlue(nn):endsBlue(nn));XDataPatch(1)];
YDataPatchN1=[YDataPatch(beginsBlue(nn):endsBlue(nn));YDataPatch(1)];
PatchyThings(XDataPatchN1,YDataPatchN1,"Blue");
XDataPatchN1=[XDataPatch(endsBlue(nn):beginsBlue(nn+1));0];
YDataPatchN1=[YDataPatch(endsBlue(nn):beginsBlue(nn+1));0];
PatchyThings(XDataPatchN1,YDataPatchN1,"Red");
else
XDataPatchN1=[XDataPatch(beginsBlue(nn):endsBlue(nn));0];
YDataPatchN1=[YDataPatch(beginsBlue(nn):endsBlue(nn));0];
PatchyThings(XDataPatchN1,YDataPatchN1,"Blue");
XDataPatchN1=[XDataPatch(endsBlue(nn):end);0];
YDataPatchN1=[YDataPatch(endsBlue(nn):end);0];
PatchyThings(XDataPatchN1,YDataPatchN1,"Red");
XDataPatchN1=[XDataPatch(end);XDataPatch(1:beginsBlue(1));0];
YDataPatchN1=[YDataPatch(end);YDataPatch(1:beginsBlue(1));0];
PatchyThings(XDataPatchN1,YDataPatchN1,"Red");
end
end
end
path='E:\Scatterer\Figures\'
exportgraphics(gcf,strcat(path,"Fig1",".png"),Resolution=300);
function PatchyThings(XDataPatchN1,YDataPatchN1,colr)
if strcmp(colr,'Red')
clr=[0.8 0.4 0.4];
else
clr=[0.6 0.7788 0.8964];
end
patch("XData",[0 XDataPatchN1'],"YData",[0 YDataPatchN1'],"ZData",[0 ones([1 length(YDataPatchN1)+1])*0.01],...
'FaceAlpha',0.65,...
'FaceColor',clr,...
'EdgeColor','none')
end

Ron
Ron 2025 年 8 月 18 日 14:56
  1 件のコメント
Star Strider
Star Strider 2025 年 8 月 20 日 12:08
@Ron --
I moved your earlier Comment to an answer. You can accept it, although no reputation points for accepting your own answer. In this instance, that only indicates that you came up with a solution to your problem.

サインインしてコメントする。

カテゴリ

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

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by