Help fixing error message: Index in position 2 exceeds array bounds (must not exceed 1).
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
Stijn Haenen
2020-7-30
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.
回答(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!