function X = intersect(A,B)
% new_X = remove_rep(Dif,X)
%
% Input Variables
%   A - First curve
%   B - Second curve
% Output Variables
%   X - intersection between two signals
%
% Description
%   reomves repeated intersections between two cell voltages.

% Created
%   8/23/2006, Mohamed A Mneimneh, Marquette University
%
% This software is released under the terms of the GNU General
% Public License (http://www.gnu.org/copyleft/gpl.html).
% Modified

X = 0;
count = 1;
for i = 1:length(A)-1
      
        if (A(i) > B(i) && A(i) < B(i+1)) || (A(i) < B(i) && A(i) > B(i+1)) 
            X(count) = i;
            count = count + 1;
        end
        
        if (B(i) > A(i) && B(i) < A(i+1)) || (B(i) < A(i) && B(i) > A(i+1))
            X(count) = i;
            count = count + 1;
        end
end
   