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!