How do I debug my matlab code?
Show older comments
Hi All,
I need some help debugging my code. It's something minor (I hope), but I can't seem to figure it out.
AbData = rand(756909,16); %%dummy data
tim_trl = 0:3.9634883453625200E-05:30-3.9634883453625200E-05; %%dummy time
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); %24 samples per 1ms
threshold = 0.018;
for channel = 1:16
data = AbData(ind1:ind2,channel);
counterMUA = 1; % needed for mua indexing
windowSt = 1; % set start point of window
for bin = 1:10000
%set end point of window
windowEnd = binWidth + windowSt - 1;
% access data in one bin
bindata = data(windowSt:windowEnd, channel); %debug here
%%calculate mua above threshold
mua(counterMUA, channel) = sum(bindata >= threshold);
counterMUA = counterMUA+1;
%slides window
windowSt = windowSt + binWidth;
end
end
This is the line of code that needs debugging:
bindata = data(windowSt:windowEnd, channel); %debug here
I know the index in position 1 exceeds array bounds, but I'm not sure how to overcome it.
Thanks in advance.
Accepted Answer
More Answers (0)
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!