Help fixing error message: Index in position 2 exceeds array bounds (must not exceed 1).
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Stijn Haenen
le 30 Juil 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.
Réponses (0)
Voir également
Catégories
En savoir plus sur Matrix Indexing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!