Replace the elements of a matrix

1 visualización (últimos 30 días)
skinny pete
skinny pete el 9 de Jun. de 2019
Comentada: Walter Roberson el 9 de Jun. de 2019
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

Respuesta aceptada

per isakson
per isakson el 9 de Jun. de 2019
Editada: per isakson el 9 de Jun. de 2019
One way
z = permute( A, [2,1] );
B = z(:);
or
z = permute( A, [2,1] );
B = reshape( z, [],1 );

Más respuestas (2)

TADA
TADA el 9 de Jun. de 2019
B = reshape(A',numel(A),1)
  1 comentario
Walter Roberson
Walter Roberson el 9 de Jun. de 2019
A' is only correct for real valued entries, as it is the conjugate transpose.

Iniciar sesión para comentar.


Walter Roberson
Walter Roberson el 9 de Jun. de 2019
B = reshape(A.',[],1);

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by