while loop index exceeds array elements problem
显示 更早的评论
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 个评论
DGM
2021-3-23
Can you paste the actual text. I'm not eager to re-type everything from a picture and then guess which errors are caused by my own typos.
mason beal
2021-3-23
mason beal
2021-3-23
mason beal
2021-3-23
DGM
2021-3-23
Is this supposed to be using MFRF40N instead of MFRF30N?
REF40N(i+1) = 4*MFRF30N/(3.14159*AV*D1);
DGM
2021-3-23
So it is supposed to be MFRF40N? Did that fix anything or change the behavior?
FWIW, I was only looking at the pattern of the code.
REF30N(i+1) = 4*MFRF30N/(3.14159*AV*D1);
...
REF40N(i+1) = 4*MFRF30N/(3.14159*AV*D1);
...
REF50N(i+1) = 4*MFRF50N/(3.14159*AV*D1);
...
REF70N(i+1) = 4*MFRF70N/(3.14159*AV*D1);
...
REF80N(i+1) = 4*MFRF80N/(3.14159*AV*D1);
If we're still stuck, you're going to have to find a way to see which variable/line number it's throwing the error at.
Mathieu NOE
2021-3-23
hello Mason
maybe you should share also the data
mason beal
2021-3-23
mason beal
2021-3-23
mason beal
2021-3-23
DGM
2021-3-23
Glad to hear it!
回答(1 个)
Veronica Taurino
2021-3-23
编辑:Veronica Taurino
2021-3-23
1 个投票
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.
类别
在 帮助中心 和 File Exchange 中查找有关 Programming 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!