필터 지우기
필터 지우기

Index in position 1 exceeds array bounds.

조회 수: 1 (최근 30일)
Maryam Almannaee
Maryam Almannaee 2021년 11월 25일
답변: Navya Singam 2021년 11월 29일
while trying to run this code an error occurs due to the first line (Happy ) and it says that
Index in position 1 exceeds array bounds.
Happy = [trainf(1,:);trainf(3,:);trainf(5,:);trainf(6,:);trainf(15,:);trainf(16,:)];
Surprise = [trainf(2,:);trainf(4,:);trainf(7,:);trainf(8,:);trainf(17,:);trainf(18,:)];
Sad = [trainf(9,:);trainf(10,:);trainf(11,:);trainf(12,:);trainf(19,:)];
Anger = [trainf(13,:);trainf(14,:);trainf(20,:)];
  댓글 수: 3
Maryam Almannaee
Maryam Almannaee 2021년 11월 25일
there is no rows, when I wrote trainf in the command window I got the below result
trainf =
[]
DGM
DGM 2021년 11월 25일
편집: DGM 2021년 11월 25일
Well then there you go. You can't extract rows that don't exist.

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

답변 (1개)

Navya Singam
Navya Singam 2021년 11월 29일
Hi Maryam,
As the trainf is an empty matrix i.e trainf=[], and you are trying to refer to the rows of an empty matrix, the code is throwing an error. Try by initializing the trainf matrix with the data and the code may work.

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by