Help fixing error message: Index in position 2 exceeds array bounds (must not exceed 1).
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi All,
Can someone please help me with my code. I get the error message "Index in position 2 exceeds array bounds (must not exceed 1)." at this point of my code, and I am not sure how to fix it:
dataBin = data(1:binWidth, jj); %data in 1 bin
My overall code:
t1 = 20; %start time, seconds
t2 = 30; %end time, seconds
ind1 = find(tim_trl>=t1, 1);
ind2 = find(tim_trl>=t2, 1); %10s time frame
time1 = tim_trl(ind1:ind2);
sampRate = 24414; %sampling freq (Hz), samples per sec
muaWindow = 0.001; %1ms window
binWidth = round(muaWindow*sampRate); %samples be 1ms
threshold = 0.018;
for jj = 1:16 %ch
data = AbData(ind1:ind2, jj);
for kk = 1:10000
abDataBin = data(1:binWidth,jj); %ab data in 1 bin
dataThreshold = find(abDataBin >= threshold); %find data points >= threshold %1 >thres; 0 <thres
mua(kk,jj) = sum(dataThreshold); %number of data over threshold per ch
end
end
Your help is appreciated. Cheers.
4 Commenti
Stijn Haenen
il 30 Lug 2020
Im not sure what you want, but your for loop for kk is not usefull. you only use kk for a matrix element and all these elements in the loop has the same value.
Risposte (0)
Vedere anche
Categorie
Scopri di più su Matrix Indexing in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!