Help fixing error message: Index in position 2 exceeds array bounds (must not exceed 1).

2 visualizzazioni (ultimi 30 giorni)
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
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.
NA
NA il 30 Lug 2020
Modificato: NA il 30 Lug 2020
Sorry, I know I’m not being clear. I’ll try and simplify it. I have a set of neural data collected across 16 different channels. I have indexed the data so that I only analyse the last 10 seconds (matrix: 244141 x 16). I want to group the data into 10000 bins across these 16 channels (0.001ms long, which is essentially 24 data points (i.e. binWidth). Within the For loop, I need to create a sliding window that shifts every 24 points (already defined as binWidth) and sums the number of data points >=threshold per bin. Ultimately, I want to left with a matrix of 10000 x 16 (all 10000 bins across 16 channels). I hope this makes more sense.

Accedi per commentare.

Risposte (0)

Prodotti


Release

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by