Hello everyone - I receive the error "Index exceeds array bounds" , but I can't solve the Problem.
I attache the file, and this is the Line which causes the error:
Pre_Time(idx_loopi).Durchschnittswert(counter,idx_act_Channel_Time)= mean(test(idx_loopi).Channels(idx_act_Channel_Time).Data(idxStart:i));

댓글 수: 3

David H
David H 2020년 6월 9일
I think the reason you are struggling to find the cause of the error is there are so many indexes used in that one line.
Maybe split it into multiple lines just for debug, something like
v1 = Pre_Time(idx_loopi)
v2 = v1.Durchschnittswert(counter,idx_act_Channel_Time);
v3 = test(idx_loopi)
v4 = v3.Channels(idx_act_Channel_Time)
v5 = v4.Data(idxStart:i));
See which gives the error
Also the for loop over "idx_loopi" appears to be over by the time you call this line, do you mean to use this index variable?
Malte Räuchle
Malte Räuchle 2020년 6월 9일
Hey David, thanks for your response. That was a good advice to split it into multiple lines. I only get an error @ v2 . But I don't get close to what could be a good solution.
Malte Räuchle
Malte Räuchle 2020년 6월 9일
And yes I want to use the index "idx_loopi" .

댓글을 달려면 로그인하십시오.

 채택된 답변

Steven Lord
Steven Lord 2020년 6월 9일

1 개 추천

Set an error breakpoint. Run your code. When MATLAB reaches the error breakpoint, check the size of v1.Durchschnittswert and the value of the counter variable. From that error message v1.Durchschnittswert will have ten rows and counter will be greater than 10.
Look back in your code to ensure that counter is being set correctly and v1.Durchschnittswert is being created and updated correctly. Did you delete a row from that variable when you didn't expect to, or did you assign into the wrong row of it (overwriting values instead of growing it?)
Once you know where the error occurs and understand what's going on, set breakpoints earlier in your code and step through, watching for the conditions that cause the error to appear.

댓글 수: 1

Malte Räuchle
Malte Räuchle 2020년 6월 10일
I set an error breakpoint and from the error PreTime.Durchschnittswert is a 1x1 struct and the counter is 1. That means that the counter is not set correctly, right?
I tried to change the position of it but my approaches do not seem to work. Any ideas?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

질문:

2020년 6월 9일

댓글:

2020년 6월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by