# Why does it give wrong answer?

6 views (last 30 days)
Sadiq Akbar on 31 Dec 2022
I took a code from the Mathworks site given below:
N = 10;
d = 0.5;
elementPos = (0:N-1)*d;
angles = [0 -25 30];
Nsig = 3;
R = sensorcov(elementPos,angles,db2pow(-5));
doa = rootmusicdoa(R,Nsig)
It works well. But when I change the 'elementPos' from linear to L-shaped array and change the angles vector to a 2 x M matrix so that to find both the angles (azimuth as well as the elevation), then it gives m the wrong answer. My modified code is as below:
clear al; clc
N = 10;
d = 0.5;
% elementPos = (0:N-1)*d;
elementPos = L1_Array(N-1);
elementPos=elementPos';
% angles = [0 -25 30];
angles = [-30 0 30; 10 20 40];
Nsig = 3;
R = sensorcov(elementPos,angles,db2pow(-5));
doa = rootmusicdoa(R,Nsig)
function r=L1_Array(N)
d = 0.5;%Inter-element spacing
rx = [(N-1)/2*d:-d:d,zeros(1,(N+1)/2)].';
ry = [zeros(1,(N+1)/2),d:d:(N-1)/2*d].';
r = [rx,ry,zeros(N,1)];
end
As can be seen, the azimuth angles are -30 0 and 30 while elevation angles are 10 20 and 40. But when I run this code, it gives me the following wrong answer:
doa =
-41.4097 -22.9068 -73.0831

### Categories

Find more on 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!