Index exceeds the number of array elements

1 回表示 (過去 30 日間)
Bertiningrum Devi
Bertiningrum Devi 2019 年 6 月 21 日
コメント済み: Bertiningrum Devi 2019 年 6 月 21 日
Hello everyone, I need some help. I'm chemical engineering student (beginner in MatLAB) trying to find the composition distribution in each tray of an absorber column.
I'm trying to use for loop to repeat calculation from tray 2 to tray 21.
So, I write the for loop j = 2:21.
when I ran the code, I type Tg(5) in the command window to see the value solved (temperature in the 5th tray) but there's a message
Index exceeds the number of array elements (3).
what's wrong? I suspect it doesn't go looping as I command.
what am I supposed to do to get it fixed?
Thank you, have a good day!
ps: I attached my m-files
  2 件のコメント
Stephen23
Stephen23 2019 年 6 月 21 日
編集済み: Stephen23 2019 年 6 月 21 日
>> size(Tg)
ans =
1 3
Why do you expect Tg to have (atleast) five elements?
None of your arrays have five elements in them, all of them have three or fewer elements.
Bertiningrum Devi
Bertiningrum Devi 2019 年 6 月 21 日
I see, I need help to overcome this problem.

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

採用された回答

infinity
infinity 2019 年 6 月 21 日
Hello,
I have tried to run you code.
I regconized that after the loop j = 2 the "errorTL = 2.0201e-06" that is smaller then "tol = 1e-5". Therefore, condition "while errorTL >= tol" is violated. Thus, for j = 3, 4, 5, .... the value of Tg could not be updated.
You should check this agan.
  1 件のコメント
Bertiningrum Devi
Bertiningrum Devi 2019 年 6 月 21 日
Ah I see. That helps so much :)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by