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 日

0 投票

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 ExchangeMatrix 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