Error While running a while loop (index exceeds number of array elements)
古いコメントを表示
回答 (1 件)
Cris LaPierre
2020 年 10 月 26 日
編集済み: Cris LaPierre
2020 年 10 月 26 日
You create variable Vdiode so that it contains a single value, 1. Then in your while condition, you try to compare the second value with the first. There is no second value, resulting in the error you see. I've transcribed the relevant parts of your code below and run it so you can see.
clear
Vdiode(1) = 1
Vdiode(2)
2 件のコメント
Mia Loposser
2020 年 10 月 26 日
Cris LaPierre
2020 年 10 月 26 日
編集済み: Cris LaPierre
2020 年 10 月 26 日
This is going to be a cyclical issue until you fix the underlying logic. Step through your code one loop at a time. There is an error around either when you increment i, or which two values you compare (right now you are including the next value. Perhaps you want to look at the previous value instead? This means (i-1) and i).
カテゴリ
ヘルプ センター および File Exchange で Resizing and Reshaping Matrices についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
