title: Numpy: Assignment and Indexing as Matlab
body: <p>Sometimes is useful to assign arrays with one index only. In Matlab this is straightforward:</p>
  
  <pre><code>M = zeros(4);
  M(1:5:end) = 1
  M =
  
     1   0   0   0
     0   1   0   0
     0   0   1   0
     0   0   0   1
  </code></pre>
  
  <p>Is there a way to do this in Numpy? First I thought to flatten the array, but that operation doesn't preserve the reference, as it makes a copy. I tried with ix_ but I couldn't manage to do it with a relatively simple syntax.</p>