Search code examples
arraysmatlabtype-conversioncell-array

Dump all values of cell array to numeric array


This is following my previous question . Assuming that I finally got that cellarray:

C = 
[10 20 30 40 50]
[10 20 30]
[10 20 30 40 50 60 70 80]
[10 20 30 40 50 60 70]
[Empty matrix 1x0]
[10 20 30 40]
[10]

How can I get to dump all these values in a single numeric array like this:

D = [10 20 30 40 50 10 20 30 10 20 30 40 50 60 70 80 10 20 30 40 50 60 70 10 20 30 40 10]

Thanks in advance for your input!!


Solution

  • You can use:

    D = horzcat(C{:})
    

    EDIT

    Thanks to @thewaywewalk, even simpler:

    D = [C{:}]