how to merge two mat files which have different structure cells into a mat file with a matrix
10 views (last 30 days)
Show older comments
quang minh le
on 22 Dec 2015
Answered: SATISH KUMAR
on 16 Apr 2017
I need to merge 1000 files with different structure cells into one matrix. For detailed, I make an examples of two files A and B files. File A has one row with n cells A = {cell(1a,1a), cell(1a,2a), .... cell(1a,na)} and B has one row and m cells B = {cell(1b,1b), cell(1b,2b), .... cell(1b,mb)}. Each cell in A and B has same 3 columns but different rows. My question is how to merge these two files with a transformation of all cell content in to ONE matrix mat file like: [cell(1a,1a); cell(1a,2a); .... cell(1a,na); cell(1b,1b); cell(1b,2b), .... cell(1b,mb)] Thanks.
2 Comments
Accepted Answer
Renato Agurto
on 22 Dec 2015
Edited: Renato Agurto
on 22 Dec 2015
I think this should do it:
for i = 1:N
A = load(file_i);
A = struct2cell(A);
f{i} = cat(1,A{:})
end
combined_f = cat(1,f{:});
3 Comments
More Answers (1)
See Also
Categories
Find more on Programming Utilities in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!