Need help on the array of matrix.

I have a matrix A in a size of n x 1, where A = [a_11 ; a_21 ; a_31 ; ......... ; a_n1]
I want to separate the row of matrix A in every j rows. Let say j = 3, which mean I will obtain:
[a_11 a_21 a_31] ; [a_41 a_51 a_61] ; ..... ; [a_(n-2)11 a_(n-1)1 a_n1]. The total matrix I will obtain is eaual to n/3.
Then I want to group them as B =
[1 a_11 a_21 a_31 ;
2 a_41 a_51 a_61 ;
3 a_71 a_81 a_91 ;
.................................................. ;
n/3 a_(n-2)1 a_(n-1)1 a_n1]

 Respuesta aceptada

Stephen23
Stephen23 el 21 de Jun. de 2023
Editada: Stephen23 el 21 de Jun. de 2023
B = reshape(A,3,[]).'

Más respuestas (0)

Categorías

Etiquetas

Preguntada:

el 21 de Jun. de 2023

Comentada:

el 22 de Jun. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by