How to remove Index exceeds matrix dimensions error ?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Akzeptierte Antwort
Iman Ansari
am 27 Apr. 2013
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 Kommentare
Iman Ansari
am 27 Apr. 2013
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
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!