How to avoid duplicate struct fields when loading structs
이전 댓글 표시
I am writing a code to automate some data processing. For this, I load in several files containing structs. I'd like to combine these structs as fields in a struct called "Data". Each file is named according to the date it was obtained.
The code is able to produce the struct with all data inside, but the structure of the struct is not as desired. For example, instead of "Data.D20190501.datainstruct" it becomes "Data.D20190501.D20190501.datainstruct". Can the desired format be achieved?
% Day strings to use in file names.
d = ["01"; "10"; "13"; "15"];
% Take files out of every folder (Day #n)
for n = 1:3
% Define path per day. (name of the struct in the file)
main = sprintf('D201905%s', d(n+1));
% Load all combined datasets.
Data.(main) = load(sprintf('../path/Day %d/file', n));
end
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Structures에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!