Matrix Elements Manipulation (Re-ordering matrices and their elements)
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Pedro Oliveira
el 24 de Oct. de 2017
Respondida: Walter Roberson
el 24 de Oct. de 2017
If I have a matrix A,
A = [1,2,3,4,5,6,7,8]
How can I turn it into a 4x2 matrix which assigns the elements row-wise, i.e.
B = [1,2; 3,4; 5,6; 7,8]
In addition, how do I go from B to A?
Thank you in advance for your help and if possible, please explain the functions used, as I wanna understand, not just have a solution.
0 comentarios
Respuesta aceptada
Walter Roberson
el 24 de Oct. de 2017
B = reshape(A,2,4).';
recreated_A = reshape(B.', 1, []);
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!