Index in position 1 exceeds array bounds (must not exceed 20598)

1 回表示 (過去 30 日間)
Américo Baptista
Américo Baptista 2021 年 5 月 17 日
回答済み: Kiran Felix Robert 2021 年 6 月 24 日
Hello,
I am using Matlab to make a Data Transformation and Analysis Project, and, honesty, I don't know that much about Matlab and can't seem to find the answer to this problem. I have tried a lot of stuff and can't seem to fix it.
The problem is on the second line of case 2. But even if I comment it, it will happen again in line 5 of case 2.
Obviously, there is a lot of code before this. If you want, I can provide it, just don't know if it is needed.
Thanks in advance!
for i=1:size(ix_labels,1) %For do número dos ID's experimentais iguais
switch all_labels((ix_labels(i,1)),3) %Switch do ID da atividade
case 1
ativid_unica = W_X{n};
ativid_unica{size(ativid_unica,2)+1} = data(all_labels(ix_labels(i,1),4):all_labels(ix_labels(i,1),5),1);
W_X{n} = ativid_unica;
ativid_unica = W_Y{n};
ativid_unica{size(ativid_unica,2)+1} = data(all_labels(ix_labels(i,1),4):all_labels(ix_labels(i,1),5),2);
W_Y{n} = ativid_unica;
ativid_unica = W_Z{n};
ativid_unica{size(ativid_unica,2)+1} = data(all_labels(ix_labels(i,1),4):all_labels(ix_labels(i,1),5),3);
W_Z{n} = ativid_unica;
case 2
ativid_unica = W_Up_X{n};
ativid_unica{size(ativid_unica,2)+1} = data(all_labels(ix_labels(i,1),4):all_labels(ix_labels(i,1),5),1);
W_Up_X{n} = ativid_unica;
ativid_unica = W_Up_Y{n};
ativid_unica{size(ativid_unica,2)+1} = data(all_labels(ix_labels(i,1),4):all_labels(ix_labels(i,1),5),2);
W_Up_Y{n} = ativid_unica;
ativid_unica = W_Up_Z{n};
ativid_unica{size(ativid_unica,2)+1} = data(all_labels(ix_labels(i,1),4):all_labels(ix_labels(i,1),5),3);
W_Up_Z{n} = ativid_unica;
case 3
ativid_unica = W_Down_X{n};
ativid_unica{size(ativid_unica,2)+1} = data(all_labels(ix_labels(i,1),4):all_labels(ix_labels(i,1),5),1);
W_Down_X{n} = ativid_unica;
ativid_unica = W_Down_Y{n};
ativid_unica{size(ativid_unica,2)+1} = data(all_labels(ix_labels(i,1),4):all_labels(ix_labels(i,1),5),2);
W_Down_Y{n} = ativid_unica;
  1 件のコメント
DGM
DGM 2021 年 5 月 17 日
編集済み: DGM 2021 年 5 月 17 日
The error is pretty straightforward. You're trying to access the 20598th element of an array. That array has fewer than 20598 elements. Is it supposed to?
What are the sizes of all the W_xxx_X, W_xxx_Y, etc cell arrays? What is n? What is the relationship of the product of that geometry to n? How is n calculated?

サインインしてコメントする。

回答 (1 件)

Kiran Felix Robert
Kiran Felix Robert 2021 年 6 月 24 日
Hi,
Refer the following answer for a clear explanation to the error.

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by