Replace the elements of a matrix

조회 수: 1 (최근 30일)
skinny pete
skinny pete 2019년 6월 9일
댓글: Walter Roberson 2019년 6월 9일
Hello everyone,
I have an A matrix as
A=[a b ; c d ; e f ; g h]
and want to get B matrix as
B=[a ; b; c; d; e; f; g; h]
using A matrix. How can I code it? Thanks

채택된 답변

per isakson
per isakson 2019년 6월 9일
편집: per isakson 2019년 6월 9일
One way
z = permute( A, [2,1] );
B = z(:);
or
z = permute( A, [2,1] );
B = reshape( z, [],1 );

추가 답변 (2개)

TADA
TADA 2019년 6월 9일
B = reshape(A',numel(A),1)
  댓글 수: 1
Walter Roberson
Walter Roberson 2019년 6월 9일
A' is only correct for real valued entries, as it is the conjugate transpose.

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


Walter Roberson
Walter Roberson 2019년 6월 9일
B = reshape(A.',[],1);

카테고리

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