polar plot and surface plot in dB scale

11 views (last 30 days)
Kiran Nadeem
Kiran Nadeem on 6 Mar 2022
Edited: Abhishek on 30 May 2025
Below is the code for planer Array factor of 10x10. I am facing diffcuilty in ploting polar and surface graph in dB scale. Formula file of array factor is also attached in PNG format. Please help
clear all;
clc;
c=3e8;
f=2.5e9; %f=2.5Ghz
lambda=c/f;
k = 2*pi/lambda; % wave number
theta0 = (0:1:360)*pi/180; %azimuth
phi0 = (-180:1:180)*pi/180; %elevation
[phi,theta]=meshgrid(phi0,theta0);
N = 10;%input('Enter the number of elements in X-axis = ')
M = 10;%input('Enter the number of elements in Y-axis = ')
dx = lambda/2; %input('Inter-Element sapcing in X-axis (in mm) = ')
dy = lambda/2; %input('Inter-Element sapcing in Y-axis (in mm) = ')
phase_x= 0;
phase_y= 0;
Shi_x = k*(dx).*sin(theta).*cos(phi) + phase_x;
Shi_y = k*(dy).*sin(theta).*sin(phi) + phase_y;
f_x = (1/N).*(sin(N*Shi_x./2))./(sin(Shi_x./2)); %normalized array factor for the distribution in x direction
f_y = (1/M).*(sin(M*Shi_y./2))./(sin(Shi_y./2)); %normalized array factor for the distribution in y direction
AF = (f_x).*(f_y);
%dBAF= 20*log10(abs(AF));
polarplot(theta, abs(AF));
%surf(phi*180/pi,theta*180/pi, abs(dBAF));
%axis([0 360 0 180 -40 40])
shading interp

Answers (1)

Abhishek
Abhishek on 30 May 2025
Edited: Abhishek on 30 May 2025
To correctly plot the planar array factor in both polar and surface plots in dB scale, please take the following considerations in mind:
  • Avoid ‘Inf’ values: Before applying the ‘log10’ function, ensure that the array factor does not contain zeros or NaN values, as this can lead to undefined or misleading results. To rectify this, replace NaNs with 0. This can be done as follows:
AF(isnan(AF)) = 0;
  • Converting to dB scale and clipping low values for visualization: Convert the magnitude of the array factor to decibels (dB) and limit the lower bound for a cleaner plot. In this case, values below -40dB has been clipped to a specific value, i.e. -40dB.
AF_dB = 20 * log10(abs(AF));
AF_dB(AF_dB < -40) = -40;
  • Polar plot at a specific elevation: For polar representation, extract a cut at a constant elevation, by selecting the appropriate index. In this case, it has been set to 90 degrees.
[~, idx_theta90] = min(abs(theta0 - pi/2));
AF_cut = AF_dB(idx_theta90, :);
polarplot(phi0, AF_cut);
rlim([-40 0]);
  • Surface Plot Rendering: The surface plot can be generated using the surf function, with the azimuth angle (in degrees) on the x-axis, elevation angle (in degrees) on the y-axis, and array factor in dB on the z-axis. Moreover, you can use a top-down view for a clearer representation, by passing value 2 to the ‘view()’ method. Here is a sample code to render the surface plot:
surf(phi0 * 180 / pi, theta0 * 180 / pi, AF_dB, 'EdgeColor', 'none');
xlabel('Azimuth Angle (°)');
ylabel('Elevation Angle (°)');
zlabel('Array Factor (dB)');
title('Array Factor Surface Plot (in dB)');
colorbar;
view(2);
shading interp;
I tested this approach using MATLAB R2024b — below is the output for your reference:
  • Polar Plot:
  • Surface Plot:
For more details, please refer the following documentations:
This should help address the problem effectively. Feel free to follow up if you have any additional questions.

Community Treasure Hunt

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

Start Hunting!