For Loop - Getting error - Index in position 2 exceeds array bounds
13 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
KSSV
2022 年 5 月 9 日
Many variables are not defined in the given code. Show us the full code, so that we can help you.
回答 (0 件)
参考
カテゴリ
Help Center および 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!