How can i add Elevation Degree to my Script?
2 views (last 30 days)
Show older comments
clc
clear all
format long %The data show that as long shaping scientific
doa=[30]/180*pi; %Direction of arrival
phi_1 = [30]/180*pi; %Azimuth Degree
theta_1 = [90]/180*pi; %Elevation Degree
N=200;%Snapshots
w=[pi/4]';%Frequency
M=3;%Number of array elements
P=length(w); %The number of signal
snr=20;%SNA
D=[1; cos(phi_1+pi/4)/sin(theta_1); sin(phi_1+pi/4)/sin(theta_1)]; %Steering vector of Single Crossed-Loop/Monopole
xx=10*rand(1,N)+1i*rand(1,N); %Simulate signal
x=D*xx;
%%
x=x+awgn(x,snr);%Insert Gaussian white noise
R=x*x'; %Data covarivance matrix
[N,V]=eig(R); %Find the eigenvalues and eigenvectors of R
NN=N(:,1:2); %Estimate noise subspace
theta=-180:0.5:180; %Peak search
phi = -180:0.5:180; %Peak Search
for ll=1:length(phi);
for ii=1:length(theta);
SS=zeros(1,3);
for jj = 0:M-1
if jj == 0
SS(1+jj) = 1; % Rumus untuk elemen pertama SS
elseif jj == 1
SS(1+jj) = cos((phi(ll)/180*pi)+pi/4)/sin(theta_1); % Rumus untuk elemen kedua SS
elseif jj == 2
SS(1+jj) = sin((phi(ll)/180*pi)+pi/4)/sin(theta_1); % Rumus untuk elemen ketiga SS
end
end
PP=SS*NN*NN'*SS';
Pmusic(ll)=abs(1/ PP);
end
end
Pmusic=10*log10(Pmusic/max(Pmusic)); %Spatial spectrum function
figure;
plot3(phi,theta,Pmusic,'-k')
xlabel('angle \phi/degree')
ylabel('angle \theta/degree')
zlabel('spectrum function P(\theta) /dB')
title('DOA estimation based on MUSIC algorithm ')
grid on
My Plot Show that the Elevation degree is not same with my theta_1
0 Comments
Accepted Answer
Rahul
on 5 Jul 2023
Hi Dion,
According to the description given by you, the below modeified code to your original code would give you elevation in your plot.
format long %The data show that as long shaping scientific
doa = [30]/180*pi; %Direction of arrival
phi_1 = [30]/180*pi; %Azimuth Degree
theta_1 = [90]/180*pi; %Elevation Degree
N = 200; %Snapshots
w = [pi/4]'; %Frequency
M = 3; %Number of array elements
P = length(w); %The number of signal
snr = 20; %SNA
D = [1; cos(phi_1+pi/4)/sin(theta_1); sin(phi_1+pi/4)/sin(theta_1)]; %Steering vector of Single Crossed-Loop/Monopole
xx = 10*rand(1,N) + 1i*rand(1,N); %Simulate signal
x = D*xx;
x = x + awgn(x, snr); %Insert Gaussian white noise
R = x*x'; %Data covariance matrix
[N,V] = eig(R); %Find the eigenvalues and eigenvectors of R
NN = N(:,1:2); %Estimate noise subspace
theta = -180:0.5:180; %Azimuth angles
phi = -180:0.5:180; %Elevation angles
Pmusic = zeros(length(phi), length(theta)); %Initialize Pmusic matrix
for ll = 1:length(phi)
for ii = 1:length(theta)
SS = zeros(1,3);
for jj = 0:M-1
if jj == 0
SS(1+jj) = 1; % Rumus untuk elemen pertama SS
elseif jj == 1
SS(1+jj) = cos((phi(ll)/180*pi)+pi/4)/sin(theta(ii)/180*pi); % Rumus untuk elemen kedua SS
elseif jj == 2
SS(1+jj) = sin((phi(ll)/180*pi)+pi/4)/sin(theta(ii)/180*pi); % Rumus untuk elemen ketiga SS
end
end
PP = SS*NN*NN'*SS';
Pmusic(ll, ii) = abs(1/PP);
end
end
Pmusic = 10*log10(Pmusic/max(Pmusic(:))); %Spatial spectrum function
figure;
surf(phi, theta, Pmusic', 'EdgeColor', 'none');
xlabel('angle \phi/degree');
ylabel('angle \theta/degree');
zlabel('spectrum function P(\theta) /dB');
title('DOA estimation based on MUSIC algorithm');
In the modified code, I have added the elevation angles (phi) and modified the loop to iterate over both azimuth (ll) and elevation (ii) angles. The Pmusic matrix is now a 2D matrix to store the spatial spectrum function for each combination of azimuth and elevation angles.
Thanks.
0 Comments
More Answers (1)
Gandham Heamanth
on 5 Jul 2023
Edited: Gandham Heamanth
on 5 Jul 2023
hi dion Akmal please have a look after updating the code:
clc
clear all
format long % The data show that as long shaping scientific
doa = [30]/180*pi; % Direction of arrival
phi_1 = [30]/180*pi; % Azimuth Degree
theta_1 = [90]/180*pi; % Elevation Degree
N = 200; % Snapshots
w = [pi/4]'; % Frequency
M = 3; % Number of array elements
P = length(w); % The number of signals
snr = 20; % SNR
D = [1; cos(phi_1+pi/4)/sin(theta_1); sin(phi_1+pi/4)/sin(theta_1)]; % Steering vector of Single Crossed-Loop/Monopole
xx = 10*rand(1,N)+1i*rand(1,N); % Simulate signal
x = D*xx;
x = x + awgn(x,snr); % Insert Gaussian white noise
R = x*x'; % Data covariance matrix
[N,V] = eig(R); % Find the eigenvalues and eigenvectors of R
NN = N(:,1:2); % Estimate noise subspace
theta_range = -180:0.5:180; % Peak search
phi_range = -180:0.5:180; % Peak search
Pmusic = zeros(length(phi_range), length(theta_range)); % Spatial spectrum function
for ll = 1:length(phi_range)
for ii = 1:length(theta_range)
SS = zeros(1,3);
for jj = 0:M-1
if jj == 0
SS(1+jj) = 1; % Rumus untuk elemen pertama SS
elseif jj == 1
SS(1+jj) = cos((phi_range(ll)/180*pi)+pi/4)/sin(theta_range(ii)/180*pi); % Rumus untuk elemen kedua SS
elseif jj == 2
SS(1+jj) = sin((phi_range(ll)/180*pi)+pi/4)/sin(theta_range(ii)/180*pi); % Rumus untuk elemen ketiga SS
end
end
PP = SS*NN*NN'*SS';
Pmusic(ll, ii) = abs(1/PP);
end
end
Pmusic = 10*log10(Pmusic/max(Pmusic)); % Spatial spectrum function
figure;
plot3(phi_range, theta_range, Pmusic, '-k')
xlabel('angle \phi/degree')
ylabel('angle \theta/degree')
zlabel('spectrum function P(\theta) /dB')
title('DOA estimation based on MUSIC algorithm')
grid on
e code:
0 Comments
See Also
Categories
Find more on Beamforming and Direction of Arrival Estimation 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!