Hello everyone,
I was wondering if anyone could help me in a simple question in matrix reshaping.
I have a 3x4 matriz M, as it follows:
M = [1 2 3 4;
5 6 7 8;
9 10 11 12]
I would like to reshape M to have the following matrix N:
N = [1 2;
3 4;
5 6;
7 8;
9 10;
11 12]
I have tried 'reshape' command, but failed. Can anyone please help?
Thanks in advance!

 Respuesta aceptada

the cyclist
the cyclist el 12 de Mayo de 2020
Editada: the cyclist el 12 de Mayo de 2020
N = reshape(M.',2,6).';
You need to transpose first (and later back again), because the reshape command works down the columns.

1 comentario

Marcello Congro
Marcello Congro el 12 de Mayo de 2020
Editada: Marcello Congro el 12 de Mayo de 2020
Thank you so much for your fast answer! I wasn't transposing twice. Now it worked! =)

Iniciar sesión para comentar.

Más respuestas (1)

BN
BN el 12 de Mayo de 2020
Hello, Try this:
Answer = reshape(M.',2,[]).';

Categorías

Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.

Productos

Versión

R2017a

Preguntada:

el 12 de Mayo de 2020

Editada:

el 12 de Mayo de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by