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!