简体   繁体   中英

How do I write handles from a MATLAB GUI into a .m file?

I am trying to create a GUI for a script that receives paths and matrix names from the user (via uigetdir and uigetfile functions as well as edit text fields), and finally upon pushing the "Run" button writes these handles into a .m file and runs another script. Essentially, in the end it should create a file called 'RunName'.m that looks something like:

base_path = get(handles.BasePathEdit,'String')

file_name = get(handles.FileNameEdit,'String')

main % runs the main script with the preceding variables defined as they were

and run it.

I'm guessing the script would run successfully if I just write it like that under the 'Run' push-button function, but I would still like for it to create a .m file as described.

Thank you very much for you help, All the best.

The simplest way of accomplishing this is to write a function that executes upon the pressing of the 'run' button that reads the values from the GUI and the proceeds with the main script. In guide, this is simple - right-click on the 'run' button, and under 'View Callbacks', select 'Callback'. Then you can use the usual syntax get(handles.RELEVANT_TEXT_BOX,'string') etc to read the resr of the data in. You can then pass this to your main function, or you could then just copy and pase your script straight into the callback.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM