Need help with a long while loop
1 view (last 30 days)
Show older comments
Miguel Alcol
on 22 Feb 2023
Commented: Miguel Alcol
on 22 Feb 2023
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.

0 Comments
Accepted Answer
Walter Roberson
on 22 Feb 2023
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.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!