title: Matlab: Creating a blockwise permutation
body: <p>I have a vector from 1 to 40 and want to shuffle it in such a way that each block of four integers (ten blocks in total) are shuffled only with themselves.</p>
  
  <p>For example: 3 4 2 1 | 7 6 5 8 | 9 11 10 12 | ...</p>
  
  <p>My original idea was to append ten permutation vectors to eachother and then add a 1 to 40 vector to the big permutation vector, but it didn't work at all as expected and was logically wrong.</p>
  
  <p>Has anyone an idea how to solve this?</p>