For Loop - Getting error - Index in position 2 exceeds array bounds
Ältere Kommentare anzeigen
I am trying to run this loop for snr and then plot snr wrt pmusic.
However, I am getting this array indexing error.
I have tried to remove ii from some variables inside the loop, re-inserted, placed differently, but the errors keep on coming.
I dont know how to solve this.
Getting this Error:
Index in position 2 exceeds array bounds (must not exceed 1).
Error in MUSIC_RMSE_wrt_SNR_08may22 (line 39)
NN(ii) = N(:,1:M-P()); %Estimate noise subspace
D=zeros(P,M); %To create a matrix with P row and M column
for k=1:P
D(k,:)=exp(-1j*2*pi*d*sin(doa(k))/lambda*[0:M-1]); %Assignment matrix
end
D=D';
xx=2*exp(j*(w*[1:N])); %Simulate signal
x=D*xx;
theta=30;
snr = 0:0.5:40;
for ii=1:numel(snr)
x1(ii)=x(ii)+awgn(x(ii),snr(ii));
R(ii) = x1(ii)*x1(ii)' %Data covarivance matrix
[N,V] = eig(R(ii)); %Find the eigenvalues and eigenvectors of R
NN(ii) = N(:,1:M-P); %Estimate noise subspace
SS=zeros(1,length(M));
for jj=0:M-1
SS(1+jj)=exp(-j*2*jj*pi*d*sin(theta/180*pi)/lambda);
end
PP=SS*NN*NN'*SS';
Pmusic(ii)=abs(1/ PP);
end
Pmusic=10*log10(Pmusic/max(Pmusic))%Spatial spectrum function
plot(snr,Pmusic,'-k')
7 Kommentare
Walter Roberson
am 8 Mai 2022
R(ii) = x1(ii)*x1(ii)' %Data covarivance matrix
[N,V] = eig(R(ii));
what is the eigenvectors of a scalar?
Umer Khalid
am 8 Mai 2022
Umer Khalid
am 8 Mai 2022
Walter Roberson
am 8 Mai 2022
What would you want the outputs to be in that case?
Umer Khalid
am 9 Mai 2022
KSSV
am 9 Mai 2022
Many variables are not defined in the given code. Show us the full code, so that we can help you.
Umer Khalid
am 9 Mai 2022
Antworten (0)
Kategorien
Mehr zu Beamforming and Direction of Arrival Estimation finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!