Appdesigner: Loading a MAT file - Difference between doing it from MATLAB vs from within Appdesigner.
조회 수: 1 (최근 30일)
이전 댓글 표시
If I load a MAT file from the MATLAB prompt e.g. load('Default_Patient.mat') it will nicely add:-
'Default_Patient 'ZaphodBeeblebrox'
...to the MATLAB Base workspace.
But, if I use the same command from within Appdesigner (even in the Startup Fn) I get:
'Default_Patient 1 x 1 struct'
where 1 x 1 struct contains: 'Default_Patient 'ZaphodBeeblebrox'
1) I don't understand why there is a difference - when it is exactly the same command.
2) Is there a way of just adding the 'ZaphodBeeblebrox' part to the Base workspace (when doing this from Appdesigner) and loading from a MAT file ?
Thank you in anticipation of a kind and helpful answer.
댓글 수: 0
답변 (1개)
Adam Danz
2020년 2월 24일
1) I don't understand why there is a difference - when it is exactly the same command.
The load command loads the data into the caller's workspace. If the caller is the command window, the data will be loaded into the base workspace. If the caller is a function, the data will be loaded into the function's workspace.
2) Is there a way of just adding the 'ZaphodBeeblebrox' part to the Base workspace (when doing this from Appdesigner) and loading from a MAT file ?
You can load specific variables using this syntax: load(filename,variables) but I recommend using the output syntax in addition to that S = load(___).
You're requesting to load data into the base workspace from app designer but then the data wouldn't be accessible in App Designer without using risky methods. Instead, load the variables within the callback function and store them directly in your app.
The callback function would look something like this after you declare FileData as a property (see link above).
% Load the variables into a structure.
S = load(filename, {'Var1', 'Var2'});
app.FileData = S;
Then you can retreive the data anywhere in your app by using
app.FileData.Var1
댓글 수: 2
참고 항목
카테고리
Help Center 및 File Exchange에서 Downloads에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!