How to load a mat.file from a selected folder to workspace from a GUI and MAINTAIN the original Data Type
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
John
am 9 Sep. 2015
Kommentiert: John
am 9 Sep. 2015
Hello,
i found this code snippet for loading a mat.file to the workspace. It works fine! The only problem is, that the file is a STRUCT!!!
When i open the file manually from the matlab surface, it is a Matrix named 'x'. Thats how i would like it to be here tooo! dont want to have a struct instead.
startingFolder = 'C:\Program Files\MATLAB'
% Get the name of the mat file that the user wants to use.
defaultFileName = fullfile(startingFolder, '*.mat')
[baseFileName, folder] = uigetfile(defaultFileName, 'Select a mat file')
if baseFileName == 0
% User clicked the Cancel button.
return;
end
fullFileName = fullfile(folder, baseFileName)
storedStructure = load(fullFileName) % only available in the GUI so far, not in the workspace
assignin('base', 'storedStructure', storedStructure); % now transported to the workspace, accessable by storedStructure.x
Can anybody help me with that plz:)
thank you very much!
Best regards, John
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 9 Sep. 2015
assignin('base', 'x', storedStructure.x); % now transported to the workspace
However, this is not recommended!
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Environment and Settings 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!