title: expand/fill-in a Matlab matrix
body: <p>I'm pretty new at Matlab so would need a baby-steps explanation.</p>
  
  <p>I have some MIDI data which looks a bit like this:</p>
  
  <p>time  on/off  note<br>
  10     1       61<br>
  90     0       61<br>
  90     1       72<br>
  92     1       87<br>
  100    0       72  </p>
  
  <p>What I want to do is expand or 'fill-in' the gaps so that I have a row for every single moment in time, and I have columns which show which notes are on (there is often more than one note at the same time).</p>
  
  <p>the ultimate goal is to do some calculations about the overall relationship between notes on (the harmonic dissonance) at a given time.</p>
  
  <p>So I was thinking that maybe I needed a new column for every single possible note (there are 127), and then a 1 or 0 for every time. Or maybe I can just have a matrix which just tells me which notes are on (so the number of columns varies).</p>
  
  <p>I wrote my own pseudo-code, but have no idea how to implement it. I suspect there is a simple function that can do this. Here is my pseudo-code:</p>
  
  <p>start with 0, at time 0 in a new 'notes-on matrix'<br>
  for numbers: 0 to n<br>
      if the number matches a number in the time column, go to the on/off column for that row.<br>
          if 1 in on/off column then copy number in notes column to 'notes-on matrix' for corresponding row<br>
          if 0 then don't copy/do nothing.  </p>
  
  <p>if number doesn't match number in time column<br>
   copy the previous row (which can be blank if there were no notes on).  </p>
  
  <p>for each row in the new 'notes-on matrix', arrange numbers low to high in different columns.</p>
  
  <p>So can anyone tell me what to do?? I'm banging my head against a brick wall here!</p>