Change, save and load .m-file parameters through GUI
Mostra commenti meno recenti
Hi there,
I've got a new question here. I am working on a GUI for a simulink model, which is now controlled by an .m-file called parameters.m. At te moment I fill in the variables in the .m-file, run this m-file and then run the simulation in Simulink.
I want to set the variables in the .m-file through my GUI, see the figure below:

I set the edit text to values. These values should be saved to the parameters.m-file. When "Calculate Tbrkth" is pressed, the parameters.m-file runs and calculates Tbrkth ( NOTE: this is another .m-file than that from the GUI! ). This value is the output of the parameters.m-file and should be shown in the GUI.
My problem is that the variable values won't be saved to the parameters.m-file. I programmed the code below in the .m-file of the GUI:
function Tbrk_Callback(hObject, eventdata, handles)
%Define Tbrk to get value from edit text box
Tbrk = get(handles.Tbrk,'String');
%Assign Tbrk to workspace
assignin('base', 'Tbrk', Tbrk);
%Save Tbrk to m-file
save('parameters.m','Tbrk');
This is my first problem I ran into. After this problem solved, I can work out my GUI further and eventually bump into new problems.
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Startup and Shutdown in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!