title: Resampled data going below 0 - MATLAB
body: <p>When resampling a large dataset down 100x - some of the data-points end up negative despite no negative numbers present in the original dataset. Is this an unavoidable consequence of the resampling process or is there a better method to accomplish this?</p>
  
  <p>I'm using:</p>
  
  <pre><code>a = resample(data,round((length(data))/1000),length(data));
  </code></pre>
  
  <p>Original dataset:</p>
  
  <p><img src="https://i.stack.imgur.com/o3k6Z.png" alt="enter image description here"></p>
  
  <p>Resampled dataset:</p>
  
  <p><img src="https://i.stack.imgur.com/XKZag.png" alt="enter image description here"></p>
  
  <p>I know that I can just filter out all values &lt;0 but I want to understand why this is happening and if there is a better way to resample as this may be skewing my results. </p>
  
  <p>Thanks!</p>
  
  <p><strong>EDIT</strong>:</p>
  
  <p>I've attempted to use interp1 to scale my data down however it has not provided the expected result so I am either using the function incorrectly or it is not the right one to use for my problem.</p>
  
  <p>The above input scaled down to:</p>
  
  <p><img src="https://i.stack.imgur.com/XE70K.png" alt="enter image description here"></p>
  
  <p>Using:</p>
  
  <pre><code>x= [1:1:230208]; %length of the imported data (hitcount)
  y = hitcount'; %hitcount is my imported data shown above
  z = [1:1:2300]; %I want to scale it down roughly 1000x
  a = interp1(x,y,z);
  </code></pre>
  
  <p><strong>EDIT 2</strong>:</p>
  
  <p>Just discovered that if I smooth my input by the same factor that i'm going to resample by (using a Hann window and <code>conv</code>) that when I resample I get a much more accurate output + very minimal negative values. </p>