How can I select a specific variable in the .mat file which contains different variables in the user interface?
Show older comments
Hi! I want to design an app which can draw with a .mat file. How can I select a specific variable in the .mat file which contains different variables in the user interface? By 'text area' or something?
Accepted Answer
More Answers (1)
Cam Salzberger
on 5 Dec 2019
Edited: Cam Salzberger
on 5 Dec 2019
0 votes
Hello Kunpeng,
You may consider using whos to determine the variables available in a MAT file. Then you can specify the variable you want when you call load based on the user selection. This will be faster than loading the entire MAT file into the workspace, unless you expect the user to frequently switch between what they want loaded.
-Cam
5 Comments
Kunpeng Zhang
on 7 Dec 2019
Kunpeng Zhang
on 8 Mar 2020
Kunpeng Zhang
on 10 Mar 2020
Stephen23
on 10 Mar 2020
"I have solved this problem with eval() function!"
A much better** solution is to load into an output variable, just like Fangjun Jiang's Answer shows, and then access its fields:
** better in the sense faster, more efficient, more robust, less buggy, much easier to debug. The approach you are using is not recommended:
Kunpeng Zhang
on 14 Mar 2020
Categories
Find more on Develop Apps Using App Designer in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!