Problem regarding to change conversion of cell2mat.

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.

 採用された回答

per isakson
per isakson 2014 年 5 月 10 日
編集済み: per isakson 2014 年 5 月 10 日

0 投票

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

1 件のコメント

Arjun
Arjun 2014 年 5 月 10 日
Thank you , its working..

サインインしてコメントする。

その他の回答 (2 件)

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 5 月 10 日

0 投票

my_cell={[1,10],[1,2,10],[1,6,10]}
my_mat=cell2mat(my_cell')

1 件のコメント

Arjun
Arjun 2014 年 5 月 10 日
my_cell={[1,10],[1,2,10],[1,6,10]}
my_mat=cell2mat(my_cell')
my_cell =
[1x2 double] [1x3 double] [1x3 double]
Error using cat Dimensions of matrices being concatenated are not consistent.
Error in cell2mat (line 84) m{n} = cat(1,c{:,n});
There is an error.About some consistent problem (may be due to each cell have unequal columns)

サインインしてコメントする。

Jos (10584)
Jos (10584) 2014 年 5 月 10 日

0 投票

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

カテゴリ

ヘルプ センター および File ExchangeStructures についてさらに検索

質問済み:

2014 年 5 月 10 日

回答済み:

2014 年 5 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by