How to reshape and rearrange a matrix in a specific way

4 visualizaciones (últimos 30 días)
Cathal White
Cathal White el 20 de Oct. de 2020
Comentada: Stephen23 el 20 de Oct. de 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.

Respuesta aceptada

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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by