Reshaping the matrix in specific order

3 visualizaciones (últimos 30 días)
Aravin
Aravin el 11 de Feb. de 2022
Respondida: Walter Roberson el 11 de Feb. de 2022
Dear all,
Lets say I have array of multiple of 6. I want to reshape that array into matrix such as there are extactly 6 columns. Lets take example,
a = [1:18]
a = 1×18
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
b = reshape(a, [3 6])
b = 3×6
1 4 7 10 13 16 2 5 8 11 14 17 3 6 9 12 15 18
I want the output should be
1 2 3 4 5 6
7 8 9 10 11 12
13 14 15 16 17 18
Anyone can help how to do it ?

Respuesta aceptada

Walter Roberson
Walter Roberson el 11 de Feb. de 2022
a = [1:18]
a = 1×18
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
b = reshape(a, 6, []).'
b = 3×6
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

Más respuestas (0)

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by