Move matrix rows and columns

조회 수: 2 (최근 30일)
Amir Ehsani
Amir Ehsani 2012년 10월 27일
I have a n*n matrix. I want to convert it to n^2*1 matrix. for example: A=[a b;c d] result B=[a;b;c;d]

채택된 답변

Matt J
Matt J 2012년 10월 27일
B=reshape(A.',[],1);
  댓글 수: 2
Matt J
Matt J 2012년 10월 27일
편집: Matt J 2012년 10월 27일
It would be better if you organized your a b c d data column-wise in A instead of row-wise. Then you wouldn't have to transpose A, which is expensive. Also, you could just do
B=A(:);
Amir Ehsani
Amir Ehsani 2012년 10월 27일
Thanks

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by