converting only certain cells to a matrix
1 view (last 30 days)
Show older comments
consider the following example
a = { rand(1877958,7); rand(1251972,7); rand(4564357,7) };
i want only the first two cells to be converted to a matrix. i know that the rows are not the same but the remaining rows can be filled with zeros. how can i do that in such a way so that the output has 14 columns meaning the matrices are put adjacent to each other. thanks
0 Comments
Accepted Answer
Azzi Abdelmalek
on 29 Nov 2014
Edited: Azzi Abdelmalek
on 29 Nov 2014
a = { rand(1877958,7); rand(1251972,7); rand(4564357,7) };
n=max(cellfun(@(x) size(x,1) , a(1:2)) )
b=cell2mat(cellfun(@(x) [x;zeros(n-size(x,1),7)],a(1:2)','un',0));
6 Comments
More Answers (0)
See Also
Categories
Find more on Data Type Conversion 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!