Another way to convert a matrix in a single vector
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Jose Antonio Salcedo Simon
el 26 de Feb. de 2018
Respondida: Bhuvnesh Singh
el 28 de Feb. de 2018
Hi sirs,
I am trying to convert a matrix into a single vector through the syntax ":" or "reshape", but they do not work as I want. They work column by column, but I want row by row, like this:
Is there any way to do this?
Thank you very very for the reply. All the best.
0 comentarios
Respuestas (1)
Bhuvnesh Singh
el 28 de Feb. de 2018
In order to achieve this, you can first take the transpose of the matrix and then apply reshape method on it.
Lets say a = [1 2; 3 4]
b = a'
vec = b(:)
You can also follow the below link: https://www.mathworks.com/matlabcentral/answers/54172-how-to-flatten-a-matrix-in-row-major-order
0 comentarios
Ver también
Categorías
Más información sobre Data Type Conversion 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!