Effacer les filtres
Effacer les filtres

while loop in file called by GUI pushbutton not working correctly

1 vue (au cours des 30 derniers jours)
Henry
Henry le 10 Juil 2013
Hi,
I'm having trouble with a while loop used in a file which is run by a GUI.
The loop keeps going until a variable (v1) reaches a limiting value, while it calculates another variable (v2) for every step v1 takes. v2 is then used to calculate other variables (v3 etc.) which are then used in a simulink model to give the value for v1.
It runs fine in the file, and when I highlight and 'evaluate section' the reference to it in the GUI this also works.
However, when I run the GUI and attempt to run it through a pushbutton v1 keeps looping at the same value. v2,v3 etc. change as usual, but v1 stays constant.
I think this is probably a problem to do with the variables being saved to the workspace correctly. Otherwise I have no idea why running through the GUI means it doesn't just run the file as normal.
I'm extremely stuck and have been for some time, so any help would be brilliant
  6 commentaires
Jan
Jan le 10 Juil 2013
@Henry: Should I assume that "Initial_Parameters_2_1" is an M-script?
Do you see that there is no hibnt how your Simulink model gets its inputs and writes its outputs? Perhaps you inject the output to the base workspace. Without knowing this, it is impossible to guess, why the program does not work as you expect it to.
Such problems are y typical effect of the transport of variables by "poofing", this means using scripts instead of functions, evalin, assignin etc.
Henry
Henry le 10 Juil 2013
Modifié(e) : Henry le 10 Juil 2013
Yes, sorry
Initial_Parameters is an m script which calculates a load of variables which are then used in the simulink model.
the other terms in the while loop are declared in the .m file called by the GUI.
This line:
t_igbt_pk = max(logsout.HP2_Thermal_Model.t_igbt.Data);
Takes the data from a subsystem 'HP2_Th..' in the model if that helps?
I think you're right in that the simulink model isnt taking updated values to calculate t_igbt_pk (as this is the only variable calculated by the simulink model).

Connectez-vous pour commenter.

Réponse acceptée

Henry
Henry le 10 Juil 2013
I have figured out how to solve this!
I needed to add this to the while loop:
options=simset('SrcWorkspace','current','DstWorkspace','current');
sim('Fixed_Freq_1_2.mdl', SimTime,options);
So that the correct workspaces were being used.

Plus de réponses (0)

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by