필터 지우기
필터 지우기

how to convert 2D matrix to 1D

조회 수: 646 (최근 30일)
Anfal
Anfal 2014년 12월 13일
편집: AIJAZ BHAT 2020년 11월 2일
i want to convert 2D array with size 83*6580 to 1D array , any help ?

답변 (2개)

Star Strider
Star Strider 2014년 12월 13일
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.
  댓글 수: 3
Stephen23
Stephen23 2018년 2월 14일
"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.
AIJAZ BHAT
AIJAZ BHAT 2020년 11월 2일
편집: AIJAZ BHAT 2020년 11월 2일
Alright I also want to add a precaution here while using it, It operates in column wise concatenation.

댓글을 달려면 로그인하십시오.


अंबरीश प्रशांत चांदूरकर 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)]);
  댓글 수: 2
Tyler David MacLean
Tyler David MacLean 2020년 10월 6일
I dig the matrix math here didnt even thing of doing it like this.
Stephen23
Stephen23 2020년 10월 6일
Simpler:
OneDArray = reshape(TwoDArray.',1,[]);

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Configure Simulation Conditions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by