How to remove Index exceeds matrix dimensions error ?
조회 수: 1 (최근 30일)
이전 댓글 표시
I am implimenting an algorithm for direction of arrival of signal estimation.For that i first store the angle information in a mat file n then loading it into the code.In this code s=a1,where a1 is the first signal and this variable contains the angle information i.e 30 degrees.but when i run my full code its giving me Index exceeds matrix dimensions error.Sir Please help me.
degree = 180; divisor_factor=32;
c = 346.287; K = 100; % Number of frequency snapshots Fs = 50000;% Sampling frequency T=1/Fs; f = 3000;% Signal frequency M = 8; dist = .03; xx = dist*[0:M-1];
theta_test = [1:1:degree-1]*pi/180; % Test vector of theta values (from 0 to 180 deg) length_t = length(theta_test); % Number of trial angles
load angledata s=a1; % a1-a5 correspond to data of 5 different incident angles % s is a 102400 by 8 matrix. The length of each of the 8 sequences may be longer than 102400 lfft=1024*1; % number of data points for FFT in a snapshot df = Fs/lfft/1; % frequency grid size F = 0:df:Fs/1-df; for ih=1:M for iv=1:K pos=(iv-1)*lfft+1; tmp=s(pos:pos+lfft-1,ih); %IN THIS ERROR IS SHOWGING X(:,ih,iv)=fft(tmp); end end
댓글 수: 0
채택된 답변
Iman Ansari
2013년 4월 27일
Hi. Maybe your s isn't 102400 by 8 matrix. With s=rand(102400,8) didn't give any error:
degree = 180; divisor_factor=32;
c = 346.287; K = 100; % Number of frequency snapshots
Fs = 50000;% Sampling frequency
T=1/Fs; f = 3000;% Signal frequency
M = 8; dist = .03; xx = dist*[0:M-1];
theta_test = [1:1:degree-1]*pi/180; % Test vector of theta values (from 0 to 180 deg)
length_t = length(theta_test); % Number of trial angles
%%%%%%%load angledata
s=rand(102400,8); % a1-a5 correspond to data of 5 different incident angles
% s is a 102400 by 8 matrix. The length of each of the 8 sequences may be longer than 102400
lfft=1024*1; % number of data points for FFT in a snapshot
df = Fs/lfft/1; % frequency grid size
F = 0:df:Fs/1-df;
for ih=1:M
for iv=1:K
pos=(iv-1)*lfft+1;
tmp=s(pos:pos+lfft-1,ih); %IN THIS ERROR IS SHOWGING
X(:,ih,iv)=fft(tmp);
end
end
댓글 수: 2
Iman Ansari
2013년 4월 27일
You can use 'for i=1:degree-1':
for i=1:degree-1
phit=-k*dist*cos(theta_test(i)); % electrical angle
for ii=1:M
v(ii,:)=exp(j*(ii-1)*phit); % array manifold matrix
end
P=v*inv(v'*v)*v'; % projection matrix wrt V
phi10_tmp(i)=trace(P*R);
end
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!