converting a cell array to a matrix

18 次查看(过去 30 天)
consider the following example
a={rand(1877958,7); rand(1251972,7)};
i want this 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?
thanks

采纳的回答

Azzi Abdelmalek
Azzi Abdelmalek 2014-11-26
a={rand(1877958,7); rand(1251972,7)};
n=max(cellfun(@(x) size(x,1),a));
b=cell2mat(cellfun(@(x) [x ;zeros(n-size(x,1),7)],a,'un',0))

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by