Matlab tool to extract data from struct to seperate .mat files
조회 수: 3 (최근 30일)
이전 댓글 표시
Hello together,
i want to build a tool (best case a GUI) where you can load in data (.mat struct files) and extract the different values to seperate .mat files which then can be saved as new .mat files.
I don't know the names of the variables in the struct.
Would be very nice to get some help from you guys, thanks!
댓글 수: 8
Stephen23
2023년 1월 2일
As Jan wrote, LOAD the MAT-file and loops over its content using FIELDNAMES():
S = load('rec1_002.mat')
A = struct2cell(S);
B = fieldnames(S);
for k = 1:numel(A)
T = cell2struct(A(k),B(k));
F = sprintf('%s.mat',B{k});
save(F,'-struct','T')
end
Checking:
dir *.mat
You can modify this to select only the MAT file that the user wants, etc.
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Workspace Variables and MAT-Files에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!