while loop index exceeds array elements problem
Ältere Kommentare anzeigen
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 Kommentare
DGM
am 23 Mär. 2021
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
am 23 Mär. 2021
mason beal
am 23 Mär. 2021
mason beal
am 23 Mär. 2021
DGM
am 23 Mär. 2021
Is this supposed to be using MFRF40N instead of MFRF30N?
REF40N(i+1) = 4*MFRF30N/(3.14159*AV*D1);
DGM
am 23 Mär. 2021
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
am 23 Mär. 2021
hello Mason
maybe you should share also the data
mason beal
am 23 Mär. 2021
mason beal
am 23 Mär. 2021
mason beal
am 23 Mär. 2021
DGM
am 23 Mär. 2021
Glad to hear it!
Antworten (1)
Veronica Taurino
am 23 Mär. 2021
Bearbeitet: Veronica Taurino
am 23 Mär. 2021
1 Stimme
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.
Kategorien
Mehr zu Programming finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!