Info
This question is closed. Reopen it to edit or answer.
Almost done, one bug left!
2 views (last 30 days)
Show older comments
I've just got one bug left to fix and I can't for the life of me get it, I thought my initial while loop should be accounting for this:
??? Attempted to access data(50945,:); index out of bounds because size(data)=[50944,1].
the total length(data) = 50944
data set:
2
31
59.35
12
59.39
2
30
55.11
14
54.82
3
3
78.98
18
68.39
21
10.23
2
30
55.11
14
54.82
etc. repeating
code:
i=1;sx=1;sy=1;j=1;xs=zeros((length(data)),(1));ys=zeros((length(data)),(1));
m=1;
while i+j < length(data)
if ceil(data(i+1,:)) == floor(data(i+1,:)) % is the second line of data a channel number?
n=0;
n=fix(data(i,:)); % tells how many trigger values there are
for j=1:2*n % iterates in groups depending on number of triggers, n
% is the channel an x or a y?
if ceil(data(i+j,:)) == floor(data(i+j,:))
if (data(i+j,1) < 16 && data(i+j,1) > -1) % its an x
if ceil(data(j+i+1,:)) ~= floor(data(j+i+1,:))
x(sx,:) = [data(i+j,:),data(j+i+1,:)];
xs(m,:)=xs(m,:)+data(j+i+1,:);
j=j+1; sx=sx+1; i=i+1;
else
j=j+1;
end
else
y(sy,:) = [data(i+j,:),data(j+i+1,:)];
ys(m,:)=ys(m,:)+data(j+i+1,:);
j=j+1; sy=sy+1;
end
else
j=j+1;
end
end
m=m+1;
i=i+1;
else
i=i+1;
end
i=i+1;
end
The fix is probably just add in an i or something... but I've been trying to fix this for about an hour and haven't figured it out... thanks in advance for any help.
0 Comments
Answers (2)
the cyclist
on 1 Aug 2011
I took the data you listed, and replicated them 3,000 times to create a dataset comparable in size to yours. Your code ran to completion for me, with no errors or warnings. (I checked that it reaches all the conditional structures, too.)
Could you post a minimal dataset that triggers the error?
0 Comments
Sean de Wolski
on 1 Aug 2011
First off, tell us what line the error is on.
if ceil(data(j+i+1,:)) ~= floor(data(j+i+1,:))
I would guess it's on this line since (i+j+1) > length(data) perhaps.
0 Comments
This question is closed.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!