Problem regarding to change conversion of cell2mat.
2 次查看(过去 30 天)
显示 更早的评论
Need help to conversion from cell to matrix.
my_cell={[1,10],[1,2,10],[1,6,10]}
my_cell =
[1x2 double] [1x3 double] [1x3 double]
>> my_mat=cell2mat(my_cell)
my_mat =
1 10 1 2 10 1 6 10
i need output in form of matrix like my_mat=[1 10 0;1 2 10;1 6 10];
some one tell me method to conversion like this.
0 个评论
采纳的回答
per isakson
2014-5-10
编辑:per isakson
2014-5-10
This
my_cell = {[1,10],[1,2,10],[1,6,10]};
cac = cellfun( @(n) [n,zeros(1,3-length(n))], my_cell, 'uni',false );
cat( 1, cac{:} )
returns
ans =
1 10 0
1 2 10
1 6 10
更多回答(2 个)
Jos (10584)
2014-5-10
This is a case for PADCAT:
my_cell={[1,10],[1,2,10],[1,6,10]}
result = padcat(my_cell{:})
PADCAT can be downloaded from the Matlab File Exchange: http://www.mathworks.com/matlabcentral/fileexchange/22909-padcat
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Cell Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!