How to modify parameters in a compile GUI by loading a file?

조회 수: 1 (최근 30일)
nicolas
nicolas 2014년 9월 3일
답변: Iain 2014년 9월 3일
Hello all,
I have a GUI with many parameters that are user defined. I compiled the GUI in an exe to use it in standalone. As there are many parameters to be set by the user I wanted to offer the possibility to save/load a "setting file" that will contain a set of parameters. I managed to do it using a .m file and it works properly when testing it in matlab. However in compile version of the GUI the load function doesn't work as it cannot interpret the .m file (that cannot be added in the dependancies when building the exe as the file may be saved by user during the use of the program and then load back). Is there a way to load a file to control the values of parameters or I am stuck with user modification when using a compile GUI?
Thanks

답변 (2개)

Salaheddin Hosseinzadeh
Salaheddin Hosseinzadeh 2014년 9월 3일
Dear Nicolas,
First of all it's such a nice idea to get the settings from the file. Sounds really cool to me.
I kind of had the same issue, but what I did was I was put a setting button on GUI that opens a question dialog and everything is initialized before, and you can change settings, but I had about 15 20 settings.
What I suggest you to do is to create a text file, and instead of load use fopen to open the file, and lets say each parameter is going to be in one line, with a name and corresponding value.
Then use fgetl to read 1 line at a time, extract the parameter name and value, and then you're done, you can close the file.
doc fopen
doc fgetl
doc fclose
Hope this helps.
Good Luck!

Iain
Iain 2014년 9월 3일
Don't use an "m" file for settings. You need to use, for example, a fixed format text file, or a fixed format excel file, or a binary file.
"xlsread" will read excel files. - This will let users edit settings files away from your GUI.
Binary files can be specific to your GUI. - This will prevent users editing & understanding settings files.
Text files can be read and edited in notepad.

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by