Merge relative cells elements into single cell
Show older comments
I have:
A = {[1:2]';[1:3]';[1:4]'};
B = {[2:3]';[2:4]';[2:5]'};
C = {[3:4]';[3:5]';[3:6]'};
I would like to merge the above listed cells to get the following:
D = {[1:2;2:3;3:4]';[1:3;2:4;3:5]';[1:4;2:5;3:6]'};
I tried something like this but can't get my head around it:
D = cellfun(@(a,b,c) {a{:} b{:} c{:}},A,B,C,'UniformOutput',false);
Can someone please help?
Thank you!
1 Comment
Stephen23
on 28 Jun 2018
Use parentheses rather than square brackets, e.g.:
A = {(1:2)';(1:3)';(1:4)'};
Accepted Answer
More Answers (0)
Categories
Find more on Matrix Indexing 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!