Index in position 1 exceeds array bounds (must not exceed 20598)
1 次查看(过去 30 天)
显示 更早的评论
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
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
2021-6-24
Hi,
Refer the following answer for a clear explanation to the error.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!