Antenna 3D pattern at any giving angle
Show older comments
Hello everyone, I have crerated a 3D Antenna Patterns (simulation) , assuming the Ant patterns (radiation) pointing at 90 degree (looking from above), my goal here, is to change the radaition angle from 90 to 15 degree or from 90 to 175 degree (at any giving angle between 15 and 175 using contour or mesh function) . I have tried the camera view and rotation function but non of that a complished my goal , eventually I will put the mesh into for-loop and view it at any giving angle, Pease help me figuer out how to solve this issue.
f= 5.04e9; %frequncy in GHz
C= 3e8; % Global constant Speed of the light
d=21.5;
G_ant=3;
x= -5:0.01:5;
%%%%%%%%%%%% **************** %%%%%%%%%%%%
y= sin(x)';
xr=x*pi/180;
yr=y*pi/180;
a=sqrt(xr.^2+yr.^2);
x1= a*f*d/C;
sinc_xA= sinc(x1)+G_ant;
A=sinc_xA.^8;
z= 40*log10(A); %% array radiation pattern in dBs
%3D-Plot
figure(1)
% [xr,yr] = meshgrid(xr,yr);
mesh(xr,yr,z*4);
view(2)
xlabel('(degrees)');
ylabel('(degrees)');
zlabel('(Direction)');
figure(2)
contour(X,Y,abs(Z));
I appreciated any help
1 Comment
Bjorn Gustavsson
on 5 Jul 2019
Maybe replace your:
view(2)
with
view(AZ,EL)
where AZ and EL are azimuth and elevation-angles in degrees.
HTH
Answers (1)
Raghunathraju
on 9 Sep 2026 at 3:49
Hi Irwin,
y = sin(x) oscillates causing the contour error, meshgrid is commented out making z compute in 1D, view(2) only moves the camera not the beam, sinc(x1) has wrong scaling and should be sinc(x1/pi), log10(A) can produce NaN without abs(), and contour uses undefined variables X,Y,Z.
The cleanest approach is to take the data you already computed and feed it directly into the Antenna Toolbox patternCustom function. This gives you proper beam steering with full interactive visualization.
patternCustom expects:
- MagE — matrix of size (phi x theta)
- theta — angles from 0° to 180°
- phi — angles from 0° to 360°
f = 5.04e9;
C = 3e8;
d = 21.5;
G_ant = 3;
% --- Step 1: Build spherical grid (required by patternCustom) ---
phi_deg = 0:2:360; % azimuth: 0 to 360 deg
theta_deg = 0:2:180; % theta: 0 to 180 deg
[PHI, THETA] = meshgrid(phi_deg, theta_deg);
% Convert to radians
phi_r = PHI * pi/180;
theta_r = THETA * pi/180;
% --- Step 2: Compute your pattern on this grid ---
az_r = phi_r;
el_r = (pi/2) - theta_r; % elevation = 90 - theta
a = sqrt(az_r.^2 + el_r.^2);
x1 = a * f * d / C;
sinc_xA = sinc(x1/pi) + G_ant; % fixed sinc scaling
A = sinc_xA .^ 8;
patdB = 40 * log10(abs(A)); % fixed abs() for safety
% patternCustom expects matrix of size (phi x theta)
MagE = patdB'; % transpose to get phi x theta
% --- Step 3: Plot using patternCustom ---
% 3D polar pattern
figure(1)
patternCustom(MagE, theta_deg, phi_deg);
title('3D Radiation Pattern - Default (90 deg)');
% Rectangular (contour-style) view
figure(2)
patternCustom(MagE, theta_deg, phi_deg, 'CoordinateSystem', 'rectangular');
title('Rectangular Pattern View');
% --- Step 4: Steer the beam to any angle between 15 and 175 ---
tilt_target_el = 15; % change this to any angle between 15 and 175
tilt_shift = round((90 - tilt_target_el) / 2);
MagE_tilted = circshift(MagE, tilt_shift, 2);
figure(3)
patternCustom(MagE_tilted, theta_deg, phi_deg);
title(sprintf('Beam steered to %d degrees', tilt_target_el));
% --- Step 5: For-loop to sweep beam from 15 to 175 degrees ---
figure(4)
for tilt_target_el = 15:10:175
tilt_shift = round((90 - tilt_target_el) / 2);
MagE_tilted = circshift(MagE, tilt_shift, 2);
patternCustom(MagE_tilted, theta_deg, phi_deg);
title(sprintf('Beam steered to %d degrees', tilt_target_el));
drawnow;
pause(0.5);
end
For more details on patternCustom you can refer the following link: patternCustom - Plot radiation pattern using spherical coordinate system (phi and theta angles) - MATLAB
Categories
Find more on Antennas, Microphones, and Sonar Transducers in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!