Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
Almost done, one bug left!
조회 수: 2 (최근 30일)
이전 댓글 표시
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
답변 (2개)
the cyclist
2011년 8월 1일
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
Sean de Wolski
2011년 8월 1일
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
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!