MATLAB: Convert matrix in single column/row vector

MATLABmatlab programming

Hi, I have to convert a matrix in one column/row vector composed of all the rows of the original matrix. How can I do this? Thanks. For example, to convert [1 2; 3 4] in to [1 2 3 4].

Best Answer

Take a look at reshape and transpose
A = [1 2 ; 3 4]
reshape(A,1,[])
transpose(A)
A.'
A(:)
reshape(A.',1,[])