MATLAB Answers

how to convert 2D matrix to 1D

조회 수: 707(최근 30일)
Anfal
Anfal 13 Dec 2014
i want to convert 2D array with size 83*6580 to 1D array , any help ?

  댓글 수: 0

로그인 to comment.

답변 수 (2)

Star Strider
Star Strider 13 Dec 2014
If you just want to make a vector out of it, use the ‘(:)’ notation:
A = rand(83,6580);
V = A(:);
‘V’ is a (546140x1) double.

  댓글 수: 2

SGUNITN
SGUNITN 14 Feb 2018
The answer is perfect and working fine.
To make V as 1D array, transpose it.
V = V'; % 1x546140
Stephen Cobeldick
Stephen Cobeldick 14 Feb 2018
"To make V as 1D array"
Unlike some languages MATLAB does not have any concept of 1D arrays: all arrays have atleast 2 explicit dimensions and infinite implicit trailing singleton dimensions. Because the first dimension is the row dimension the most "basic" kind of vector is actually a column vector.

로그인 to comment.


Ambarish Prashant Chandurkar
To Convert a 2D Matrix into a 1D Array( i.e a row vector), such that row vector is formed by concatenating consecutive rows of the 2D Matrix, use the following Code :
OneDArray = reshape(TwoDArray',[1 size(TwoDArray,1)*size(TwoDArray,2)]);

  댓글 수: 0

로그인 to comment.

이 질문에 답변하려면 로그인을(를) 수행하십시오.


Translated by