3D pattern plotting function seems to be wrong !

I wrote the following function for plotting 3D pattern of an array with position vectors in a matrix named ``RIS'' and the beamforming weights in W, there seems to be an error which I am unable to locate, any comments ?
function [G] = Full_3D_Pattern (W, RIS)
theta = -pi/2 : pi/2e2 : pi/2; phi = theta; %angle steps of 1 degree for plotting
G = zeros ( length(theta), length(phi) );
A = zeros ( length(W), length(theta), length(phi) );
for k = 1:length(phi)
for tta = 1:length(theta)
ux = cos(phi(k))*sin(theta(tta));
uy = cos(phi(k))*cos(theta(tta));
uz = sin (phi(k));
u = [ux; uy; uz];
A (:,tta,k) = exp (-1i*pi*u'*RIS); % RIS steering vector for tta, k
G (tta,k) = abs(W' * A (:,tta,k)) * cos(theta(tta))*cos(phi(k)) * 2;
end
end
figure('Name','3D Pattern')
set(0,'DefaultAxesFontSize',20,'DefaultTextFontSize',20);
mesh(theta,phi,abs(G).^2);xlim([-pi/2 pi/2]);ylim([-pi/2 pi/2]); %%%% radian space
xlabel('Phi','FontSize',22); ylabel('Theta','FontSize',22); colorbar
end

6 Comments

Can you provide RIS and W in a mat file?
RIS_Full.mat and W.mat are attached.
W.mat I get from the following function for steering at el = -45*pi/180; and az = -pi/3
function [WS] = Steering (RIS, el, az)
Sx = cos(el) * sin(az); Sy = cos(el)*cos(az); Sz = sin(el); %Steering direction co-ordinates
% St = [Sx,Sy,Sz].'; %Steering direction unit vector
St = [Sx; Sy; Sz];
J = sqrt(-1); WS = exp ( -J*pi*(St'*RIS) ); % RIS steering vector for the steering direction S
% A = exp(-J*pi*(r'*P));
end
Or for simplicity, RIS and W are as in
clear; clc; close all;
NpH = 64; % # of RIS elements per sub-array
NpV = 5;
RIS_X = ( 0 : (NpH-1) ); % X range of RIS co-ordinates
RIS_X = kron ( ones(1,NpV) , RIS_X );
RIS_Z = ( 0 : (NpV-1) );
RIS_Z = kron ( RIS_Z, ones(1,NpH) );
RIS = [ RIS_X ; zeros(1,NpH*NpV) ; RIS_Z ];
% figure()
% plot3 ( RIS(1,:), RIS(2,:), RIS(3,:), '*'); hold on;
el = -45*pi/180;
az = -pi/3;
Sx = cos(el) * sin(az); Sy = cos(el)*cos(az); Sz = sin(el); %Steering direction co-ordinates
St = [Sx; Sy; Sz];
W = exp ( -1i*pi*(St'*RIS) );
Full_3D_Pattern ( ones(320,1).*W.', RIS );
The code runs without error. Is there a problem with the result?
LD1 = load('RIS_Full.mat');
RIS = LD1.RIS_Full;
LD2 = load('W.mat');
W = LD2.W;
G = Full_3D_Pattern (W, RIS);
function [G] = Full_3D_Pattern (W, RIS)
theta = -pi/2 : pi/2e2 : pi/2; phi = theta; %angle steps of 1 degree for plotting
G = zeros ( length(theta), length(phi) );
A = zeros ( length(W), length(theta), length(phi) );
for k = 1:length(phi)
for tta = 1:length(theta)
ux = cos(phi(k))*sin(theta(tta));
uy = cos(phi(k))*cos(theta(tta));
uz = sin (phi(k));
u = [ux; uy; uz];
A (:,tta,k) = exp (-1i*pi*u'*RIS); % RIS steering vector for tta, k
G (tta,k) = abs(W' * A (:,tta,k)) * cos(theta(tta))*cos(phi(k)) * 2;
end
end
figure('Name','3D Pattern')
set(0,'DefaultAxesFontSize',20,'DefaultTextFontSize',20);
mesh(theta,phi,abs(G).^2);xlim([-pi/2 pi/2]);ylim([-pi/2 pi/2]); %%%% radian space
xlabel('Phi','FontSize',22); ylabel('Theta','FontSize',22); colorbar
end
.
Yes, there is a problem, if you give el = az = 0, then you get a fan / blade beam, when you steer it, it gets curved -- just steering causes the curvature -- it should not !!
For el = az = 0, use W = ones (320,1), sorry i should have written it earlier .

Sign in to comment.

Answers (0)

Categories

Find more on Vehicle Dynamics Blockset in Help Center and File Exchange

Products

Release

R2019b

Community Treasure Hunt

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

Start Hunting!