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

7 Ansichten (letzte 30 Tage)
Américo Baptista
Américo Baptista am 17 Mai 2021
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 Kommentar
DGM
DGM am 17 Mai 2021
Bearbeitet: DGM am 17 Mai 2021
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?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Kiran Felix Robert
Kiran Felix Robert am 24 Jun. 2021
Hi,
Refer the following answer for a clear explanation to the error.

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by