Saturday, May 17, 2014

Selectively Removing the Polar Axis Labels in Matlab

In Matlab polar plots, the default is to show the whole 360 degrees of the whole graph and also include the polar labels up to 360. If some of the labels are desired not the displayed selectively, one remedy is to replace the corresponding strings with empty string. The procedure is pretty simple and I am showing it below.

First assume that we have such a code that plots the polar plot of a radiation pattern of an antenna array.

set(0,'defaultFigureColor',[1 1 1]) 

clear all; clc;

freq=1e9;
c=3e8;
lambda=c/freq;
T= 1/freq;
omega=2*pi*freq;
k=2*pi/lambda;

Ns=20;
ds=lambda/Ns;

Nt=25;
dt=T/Nt;
t=0:dt:(1*T);

R=(0*lambda):ds:(8*lambda);
Ntheta=240;
dtheta=2*pi/Ntheta;

theta=0:dtheta:(2*pi);


x=R.'*cos(theta);
y=R.'*sin(theta);

delta=(pi/3);

figure (10); clf; 
d = lambda/2;
A = [1 1 1 1 1 1 1]; % Amplitude of each array antenna
Fa=zeros(1,length(theta));
for i=0:(7-1)
    temp =  (A(i+1) * exp(-1i*i*delta + 1i*k*(i*d-3*d)*cos(theta)));
    Fa = Fa + temp;
end
Fa=abs(Fa);
kk=polar(theta,-Fa/max(Fa));   hold on; axis off;
 
The resulting plot is shown below where polar labels up to 330 degrees are shown.

Assume that we do not want to display the labels larger than 180 degrees, the remedy is simply to find the corresponding handle to that string and then replace it with empty string as shown below.
set(findall(gca,'String','210'),'String',' ') set(findall(gca,'String','240'),'String',' ') set(findall(gca,'String','270'),'String',' ') set(findall(gca,'String','300'),'String',' ') set(findall(gca,'String','330'),'String',' ')
 

No comments:

Post a Comment