MATLAB: How to concatenate cells in each row in a matrix

MATLAB: How to concatenate cells in each row in a matrix

MATLAB

Dear Matlab users,
I need to cancat each row’s cell in a matrix, For example: I have this matrix:
8 1 6
3 5 7
4 9 2
My goal is to have this form: 816, 357, 492.
I am beginner with matlab. I would be very grateful if you could help me. Thanks in advance.

Best Answer

  • a = [ 8 1 6 ; 1 2 3 ; 4 5 6 ]
    [l c ] = size (a) ;
    b = cell (l,1);
    for i =1 : l
    b {i,: } = [ a(i,1) a(i,2) a(i,3) ] ;
    end
  • Add a Comment

    Your email address will not be published. Required fields are marked *