MATLAB: Problem regarding to change conversion of cell2mat.

catcell2matconcatenatepadcat

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.

Best Answer

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