Replace the elements of a matrix

19 次查看(过去 30 天)
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