while loop index exceeds array elements problem

1 回表示 (過去 30 日間)
mason beal
mason beal 2021 年 3 月 23 日
編集済み: Veronica Taurino 2021 年 3 月 23 日
I am trying to run multiple iterations of this while loop to determine the reynolds number for various mass flow rates.. The first loop works perfectly, but when it gets to the second loop it gives me the error "Index exceeds array elements (1)" which is odd because I set up both loops the same way.. I tried reloading matlab but got the same
  11 件のコメント
mason beal
mason beal 2021 年 3 月 23 日
I was able to figure it out.. The original while loop changed the i value to 8 so when the next tried to run it was stuck at 8. So I switched my variable to j then k etc. for the other loops. Thank you to everyone that helped I really appreciate it :).
DGM
DGM 2021 年 3 月 23 日
Glad to hear it!

サインインしてコメントする。

回答 (1 件)

Veronica Taurino
Veronica Taurino 2021 年 3 月 23 日
編集済み: Veronica Taurino 2021 年 3 月 23 日
Did you check your variable "i" has been set up to your desired value in the second while? Because in the first while you are updating it, so that the final value of ''i'' from the first "while" will be the input "i" for the second while.

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by