For Loop - Getting error - Index in position 2 exceeds array bounds
이전 댓글 표시
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
Walter Roberson
2022년 5월 8일
R(ii) = x1(ii)*x1(ii)' %Data covarivance matrix
[N,V] = eig(R(ii));
what is the eigenvectors of a scalar?
Umer Khalid
2022년 5월 8일
Umer Khalid
2022년 5월 8일
Walter Roberson
2022년 5월 8일
What would you want the outputs to be in that case?
Umer Khalid
2022년 5월 9일
KSSV
2022년 5월 9일
Many variables are not defined in the given code. Show us the full code, so that we can help you.
Umer Khalid
2022년 5월 9일
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Beamforming and Direction of Arrival Estimation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!