How to load a mat.file from a selected folder to workspace from a GUI and MAINTAIN the original Data Type
조회 수: 2 (최근 30일)
이전 댓글 표시
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
채택된 답변
Walter Roberson
2015년 9월 9일
assignin('base', 'x', storedStructure.x); % now transported to the workspace
However, this is not recommended!
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Environment and Settings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!