필터 지우기
필터 지우기

how to convert 2-D array to 1-D array

조회 수: 4 (최근 30일)
Ashraf Hisham
Ashraf Hisham 2018년 4월 17일
댓글: Guillaume 2018년 4월 17일
how to convert 2-D array of dimension n*m to 1-D array with length (n*m) if a=[1 2 3;4 5 6;7 8 9] i want a = [1 2 3 4 5 6 7 8 9] so how

채택된 답변

Guillaume
Guillaume 2018년 4월 17일

transpose then reshape

a = reshape(a.', 1, [])

추가 답변 (1개)

Bosong Lin
Bosong Lin 2018년 4월 17일
Hey,
Try this. A = [1,2;3,4]; A = A(:);
  댓글 수: 1
Guillaume
Guillaume 2018년 4월 17일
Ashraf wants the reshaping done by row, this would do it by column which is not what is asked. It produces [1;3;2;4] instead of [1,2,3,4]

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

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by