Error: Index in position 2 exceeds array bounds (must not exceed 155).

3 views (last 30 days)
I get this error: Index in position 2 exceeds array bounds (must not exceed 155). Why??
for i= 1:length(FRI_10000_DOK_nonan)
Z1(i,:)= 1:155;
if isnan(Zeit_Flutende_10000_BA_nonan(i,:))== 1 | Zeit_Flutende_10000_BA_nonan(i,:)==0
Y_draw_10000_BA(i,[1:50])= nan;
FRI_HQ10000_draw_BA(i,[1:50])= nan;
Y_draw_10000_BA(i,:) = Z1(i,Zeit_Flutende_10000_BA_nonan(i,:):(Zeit_Flutende_10000_BA_nonan(i,:)+49)) ;
FRI_HQ10000_draw_BA(i,:) = FRI_10000_DOK_nonan(i,Zeit_Flutende_10000_BA_nonan(i,:))+slope_HQ10000_BA(i,:)*(Y_draw_10000_BA(i,:)-Y_draw_10000_BA(i,1)); % 10 samples before end point + slope = line
  1 Comment
KSSV on 28 Jun 2022
The mat files which you have uploaded and the variables given in the code, do not match. There are some undefined variables.

Sign in to comment.

Answers (1)

Sai Charan Sampara
Sai Charan Sampara on 28 Jun 2022
Edited: Sai Charan Sampara on 28 Jun 2022
The only two places where there is a variable in 2nd index place is in these two lines.
Y_draw_10000_BA(i,:) = Z1(i,Zeit_Flutende_10000_BA_nonan(i,:):(Zeit_Flutende_10000_BA_nonan(i,:)+49)) ;
FRI_HQ10000_draw_BA(i,:) = FRI_10000_DOK_nonan(i,Zeit_Flutende_10000_BA_nonan(i,:))+slope_HQ10000_BA(i,:)*(Y_draw_10000_BA(i,:)-Y_draw_10000_BA(i,1));
So make sure that ,
Zeit_Flutende_10000_BA_nonan(i,:)+49 < size(Z1,2) and
Zeit_Flutende_10000_BA_nonan(i,:) < size(FRI_10000_DOK_nonan,2)

Community Treasure Hunt

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

Start Hunting!