Need help with a long while loop

1 vue (au cours des 30 derniers jours)
Miguel Alcol
Miguel Alcol le 22 Fév 2023
Commenté : Miguel Alcol le 22 Fév 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.

Réponse acceptée

Walter Roberson
Walter Roberson le 22 Fév 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.
  1 commentaire
Miguel Alcol
Miguel Alcol le 22 Fév 2023
Thanks man, that was the problem.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Tags

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by