Replace the elements of a matrix

15 ビュー (過去 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 );
  1 件のコメント
skinny pete
skinny pete 2019 年 6 月 9 日
Thank you per.

サインインしてコメントする。

その他の回答 (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 Center および File ExchangeMatrices and Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by