How to load .mat file to base workspace using App Designer?
33 ビュー (過去 30 日間)
表示 古いコメント
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 件のコメント
回答 (1 件)
Image Analyst
2023 年 6 月 1 日
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.
参考
カテゴリ
Help Center および File Exchange で Data Import and Analysis についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!