How to load a mat.file from a selected folder to workspace from a GUI and MAINTAIN the original Data Type
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Walter Roberson
le 9 Sep 2015
assignin('base', 'x', storedStructure.x); % now transported to the workspace
However, this is not recommended!
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Environment and Settings dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!