How to reshape and rearrange a matrix in a specific way

3 Ansichten (letzte 30 Tage)
Cathal White
Cathal White am 20 Okt. 2020
Kommentiert: Stephen23 am 20 Okt. 2020
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.

Akzeptierte Antwort

KSSV
KSSV am 20 Okt. 2020
Bearbeitet: KSSV am 20 Okt. 2020
If A is matrix. USe
iwant = A(:)
Example:
A = [0, 0; -0.001, 0; 0, 0.02] ;
A = A' ;
iwant = A(:)
  3 Kommentare
Cathal White
Cathal White am 20 Okt. 2020
Brilliant. That edit worked. Thanks.
Stephen23
Stephen23 am 20 Okt. 2020
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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Produkte


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by