How to reshape and rearrange a matrix in a specific way

4 ビュー (過去 30 日間)
Cathal White
Cathal White 2020 年 10 月 20 日
コメント済み: Stephen23 2020 年 10 月 20 日
How can I rearrange the following 3x2 matrix: [0, 0; -0.001, 0; 0, 0.02]
to look like this 6x1: [0; 0; -0.001; 0; 0; 0.02]?
I've tried the reshape function but think I'm using the wrong arguments. Thanks.

採用された回答

KSSV
KSSV 2020 年 10 月 20 日
編集済み: KSSV 2020 年 10 月 20 日
If A is matrix. USe
iwant = A(:)
Example:
A = [0, 0; -0.001, 0; 0, 0.02] ;
A = A' ;
iwant = A(:)
  3 件のコメント
Cathal White
Cathal White 2020 年 10 月 20 日
Brilliant. That edit worked. Thanks.
Stephen23
Stephen23 2020 年 10 月 20 日
Rather than using complex conjugate transpose, it is better to use transpose:
>> A = [0, 0; -0.001, 0; 0, 0.02]
A =
0.0000 0.0000
-0.0010 0.0000
0.0000 0.0200
>> B = A.';
>> B = B(:)
B =
0.0000
0.0000
-0.0010
0.0000
0.0000
0.0200

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by