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]

 Réponse acceptée

Stephen23
Stephen23 le 21 Juin 2023
Modifié(e) : Stephen23 le 21 Juin 2023
B = reshape(A,3,[]).'

Plus de réponses (0)

Catégories

Community Treasure Hunt

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

Start Hunting!

Translated by