Need help with a long while loop

1 回表示 (過去 30 日間)
Miguel Alcol
Miguel Alcol 2023 年 2 月 22 日
コメント済み: Miguel Alcol 2023 年 2 月 22 日
Hi!
Im currently doing my uni thesis about simulation of photovoltaic installations with Matlab. I have this huge while loop where I have a menu function inside. This loop break when you ONLY choose the last 2 option who put the variable exit=1, and my while is while exit==0.
So, the thing is when i tried to add a .mat archive (50x40 double) the menu closes by pressing any button.
I already have 400 lines of code inside the while, i dont know if this is too heavy for Matlab or what. I dont have any idea of computing tough.
If i delete the line which load the archive -> load('archive'); the problem is solved and my menu reopen when it finishes the chosen option.
Any help is welcome. Thank you!
PD: 100% is not a code error, it has to be a memory problem or something i dont understand yet.

採用された回答

Walter Roberson
Walter Roberson 2023 年 2 月 22 日
load('archive');
loads every variable in archive.mat overwriting existing variables of the same name. One of the variables you are loading is overwriting the variable you are using to control the loop.
You should assign the result of the load to a variable. The result will be a struct with one field for each variable loaded. Extract the variables you need from the struct.
  1 件のコメント
Miguel Alcol
Miguel Alcol 2023 年 2 月 22 日
Thanks man, that was the problem.

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

その他の回答 (0 件)

カテゴリ

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

タグ

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by