Asked by parul
on 29 Apr 2013

Sir , i m implimenting ESPRIT algo to find DOA of a signal bt getting an error in findind u1 in the following code.

d=.5; lamda=1; thetaest1=[]; thetaest2=[]; thetaest3=[]; for i=1:2500; M=6; N=200;

data1=sign(2*rand(1,N)-1); data2=sign(2*rand(1,N)-1); data3=sign(2*rand(1,N)-1); SNR1=2; SNR2=2; SNR3=2;

s1=sqrt(10^(SNR1/10))*data1; s2=sqrt(10^(SNR2/10))*data2; s3=sqrt(10^(SNR3/10))*data3;

theta1=(pi/180)*82; theta2=(pi/180)*90; theta3=(pi/180)*98;

i=1:M; A1=exp(-j*2*pi*d*(i-1)*cos(theta1)); A2=exp(-j*2*pi*d*(i-1)*cos(theta2)); A3=exp(-j*2*pi*d*(i-1)*cos(theta3));

Z=eye(8); J0=Z(1:7,:); J1=Z(2:8,:); L=[J0;J1]; u1=L*A1'*s1+L*A2'*s2+L*A3'*s3; %error here

n1=sqrt(.5)*randn(size(u1))+j*sqrt(.5)*randn(size(u1)); X1=n1+u1; Rxx=zeros(2*(M-1),2*(M-1)); for k=1:200; Rxx=Rxx+X1(:,k)*X1(:,k)'; end; Rxx=Rxx/200;

[V D]=eig(Rxx); Es=V(:,[8:10]); E=Es; E0=E(1:5,1:3); E1=E(6:10,1:3); E2=[E0';E1]*[E0 E1];

[V1 D1]=eig(E2); E12=V1(1:3,3:5); E22=V1(3:5,3:5);

H=-E12*inv(E22); [V2 D2]=eig(H);

z=angle(D3); Y=sort(diag(z)); angle_estim1=acos(Y(3,1)/pi)/pi*180; angle_estim2=acos(Y(2,1)/pi)/pi*180; angle_estim3=acos(Y(1,1)/pi)/pi*180;

thetaest1=[thetaest1 angle_estim1]; thetaest2=[thetaest2 angle_estim2]; thetaest3=[thetaest3 angle_estim3]; end; thetaest=[thetaeat1 thetaest2 thetaest3]; span=[1:.1:130];

hist(thetaest,span); ylabel('histogram'); xlabel('DOA(angle)');

*No products are associated with this question.*

Answer by the cyclist
on 29 Apr 2013

Edited by the cyclist
on 29 Apr 2013

I was not able to identify one simple error. You seem to have a few potential issues with your code. One thing I noticed is that you define

i=1:M;

inside a for loop in which *i* is ranging from 1:2500. So, the code is not clear to me. You also have a mix of several variables of different sizes, that all get multiplied together in the line of code that is giving the error. But I could not sort it out.

Are you familiar with debug mode? I recommend that you digest the information on this page: http://www.mathworks.com/help/matlab/debugging-code.html.

I suggest you add a breakpoint to your code on the line that gives the error, and then you can see all the different sizes of the variables at that moment in the code. Maybe you can get a hint about what's unexpected.

Related Content

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today
## 0 Comments