title: Finding zero crossing that are going positive and zero crossing that are going negative
body: <p>I have a signal that I would like to copy when it:</p>
  
  <p><strong>1) starts at zero crossing going positive</strong></p>
  
  <p>2) copy a set number of points (like 8000)</p>
  
  <p><strong>3) and after the 8000 points are copied continue appending points until a zero crossing going down section is found.</strong></p>
  
  <p>I can find the zero crossing but I'm having some issues with knowing how to tell when there is a zero crossing going positive and/or a zero crossing going negative.  I'm also having trouble with adding the next section of points after the 8000 points at the end (So question <strong>#1</strong> and question <strong>#3</strong> <strong>in bold</strong> I'm have issues with) </p>
  
  <p>Note: please keep in mind the signal I'm using is an audio signal so it won't be as nice as a simple equation.</p>
  
  <p>I've attached the test code along with an image.  I'm using matlab / octave</p>
  
  <pre><code>clear all, clc, tic, clf;
  n=16000
  t=linspace(0,2*pi,n);
  y=cos(6*t)+sin(4*t);
  
  %find zero crossings
  t1=y(1:n-1);
  t2=y(2:n);
  tt=t1.*t2;
  indx=find(tt&lt;0)
  
  %1) start at first zero crossing going positive 
  %2) get 8000 pts 
  %3) and after the 8000 points continue appending points until a zero crossing going down section is found
  new_y=y(indx(1,1):8000); %start at zero section found get 8000 pts
  subplot(2,1,1);plot(y);title('Original Signal')
  subplot(2,1,2);plot(new_y);title('New signal')
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/9D8KP.png" alt="enter image description here"></p>