Index exceeds the number of array elements (2).Please help ?

조회 수: 1 (최근 30일)
S Priya
S Priya 2021년 6월 29일
댓글: S Priya 2021년 6월 29일
h=1;
Ha=[-0.5;0.5]*h;
for i=1
h1=Ha('1,i');h2=Ha('2,i');
hnl=h2-h1;
end

채택된 답변

KSSV
KSSV 2021년 6월 29일
편집: KSSV 2021년 6월 29일
Check your syntax. Indexing should be integers not strings. When you use ' ', this will be a string.
h=1;
Ha=[-0.5;0.5]*h;
for i=1
h1=Ha(1,i);
h2=Ha(2,i);
hnl=h2-h1;
end
  댓글 수: 2
Rik
Rik 2021년 6월 29일
I still dislike the choice Mathworks made when picking the name for the string datatype. The documentation is still littered with mentions of 'string' where they mean char array instead. When there wasn't a string datatype there wasn't any confusion.
In short, I have a meaningless correction for this answer: single quotes create a char, not a string.
S Priya
S Priya 2021년 6월 29일
Thank you.

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by