Skip to main content
edited body
Source Link
space_voyager
  • 2k
  • 3
  • 24
  • 33

I have the following vector u:

u=[a1,a2,a3,a4,b1,b2,b3,b4,c1,c2,c3,c4]; 

I want to permute the elements of of u to make the following vector, uNew:

uNew=[a1,b1,c1,a2,b2,c2,a3,b3,c3,a4,b4,c4]; 

I can think of no way of doing this other than with a for loop:

uNew=[]; for i=1:34 uNew=[uNew,u(i:34:end)]; end 

But I'm hoping that a built-in function exits? Thanks!

I have the following vector u:

u=[a1,a2,a3,a4,b1,b2,b3,b4,c1,c2,c3,c4]; 

I want to permute the elements of of u to make the following vector, uNew:

uNew=[a1,b1,c1,a2,b2,c2,a3,b3,c3,a4,b4,c4]; 

I can think of no way of doing this other than with a for loop:

uNew=[]; for i=1:3 uNew=[uNew,u(i:3:end)]; end 

But I'm hoping that a built-in function exits? Thanks!

I have the following vector u:

u=[a1,a2,a3,a4,b1,b2,b3,b4,c1,c2,c3,c4]; 

I want to permute the elements of of u to make the following vector, uNew:

uNew=[a1,b1,c1,a2,b2,c2,a3,b3,c3,a4,b4,c4]; 

I can think of no way of doing this other than with a for loop:

uNew=[]; for i=1:4 uNew=[uNew,u(i:4:end)]; end 

But I'm hoping that a built-in function exits? Thanks!

Source Link
space_voyager
  • 2k
  • 3
  • 24
  • 33

Matlab: reshape a vector by permuting?

I have the following vector u:

u=[a1,a2,a3,a4,b1,b2,b3,b4,c1,c2,c3,c4]; 

I want to permute the elements of of u to make the following vector, uNew:

uNew=[a1,b1,c1,a2,b2,c2,a3,b3,c3,a4,b4,c4]; 

I can think of no way of doing this other than with a for loop:

uNew=[]; for i=1:3 uNew=[uNew,u(i:3:end)]; end 

But I'm hoping that a built-in function exits? Thanks!