Convert cell array to an array, when the size of the cells is different

4 views (last 30 days)
Hi all,
I have a cell array like this A={ [0 0 0 0] ; [1 1] ;[2] }
Is it possible to convert it in an array? I tried with cell2mat but I get an error because the sizes are different
thanks
Nikolas

More Answers (1)

madhan ravi
madhan ravi on 4 Dec 2018
[A{:}] % which is eqivalent to horzcat(A{:})
  3 Comments
Nikolas Spiliopoulos
Nikolas Spiliopoulos on 4 Dec 2018
well it's from a for loop that the results are saved in A by using
A{i,1)=...
So for the example above I would like to get
B=[0 0 0 0; 1 1 0 0 ; 2 0 0 0 ]
So actyally putting zeros where the elements are less

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!