Why do I receive error "Index in position 2 exceeds array bounds"

Hi,
In MATLAB AppDesigner, I have written this code. Everything is fine except line CLTDRR = app.CLTDR (1,app.hr) where I am trying to get a specific number from an array app.CLTDR. app.hr is always less than or equal to 24 based on input but it still shows the error "Index in position 2 exceeds array bounds (must not exceed 24)". But app.hr is never greater than 24. Also, CLTDRR is a 1 row and 24 column vector.

 채택된 답변

Bora Eryilmaz
Bora Eryilmaz 2022년 12월 8일
편집: Bora Eryilmaz 2022년 12월 8일
Print out what app.hr is. It is likely a string and not a numerical value since you are reading it from the drop down widget. If it is really a string (or a char array), you can use
value = str2num(app.hr)
to convert it to a numeric value.

댓글 수: 1

Haris Riaz
Haris Riaz 2022년 12월 8일
편집: Haris Riaz 2022년 12월 8일
Thank you very much, @Bora Eryilmaz. Means a lot. It resolved my issue.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

질문:

2022년 12월 8일

편집:

2022년 12월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by