How to load .mat file to base workspace using App Designer?
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hey, I would like to load a .mat file to workspace using buttonpushed callback function:
When I pushed the button uigetfile function will run and I will choose the mat file that I want to load it to base workspace.
[file,path] = uigetfile('*.m','Choose File');
data = load([path,file]);
The .mat file is loading into app.data struct but it could not read from workspace.
0 Kommentare
Antworten (1)
Image Analyst
am 1 Jun. 2023
It's usually not a good idea to load variables into the base workspace. It's best if you just load it into your program as a global variable hanging off the app structure.
[baseFileName, folder] = uigetfile('*.m','Choose File');
fullFileName = fullfile(folder, baseFileName)
app.storedDataStructure = load(fullFileName)
Why do you think you want/need it in the base workspace instead of only in the scope of your program?
Don't use path as the name of your variable since it's the name of an important built-in global variable.
Also, it might be good to pre-load all the .mat files into a drop down list or a listbox. Much friendlier to the user.
Siehe auch
Kategorien
Mehr zu Workspace Variables and MAT Files finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!