How to load a mat.file from a selected folder to workspace from a GUI and MAINTAIN the original Data Type
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
John
el 9 de Sept. de 2015
Comentada: John
el 9 de Sept. de 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 comentarios
Respuesta aceptada
Walter Roberson
el 9 de Sept. de 2015
assignin('base', 'x', storedStructure.x); % now transported to the workspace
However, this is not recommended!
Más respuestas (0)
Ver también
Categorías
Más información sobre Environment and Settings en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!