title: Band pass implementation matlab
body: <p>I've 2 raw signals X and Y measuring vibrations of a rotating shaft at const. speed 633.33 Hz. My goal is to extract only specific frequency component (say 1X or .35X)and plot orbits (X signal plotted against Y signal) for them. I took the raw signal and I applied the low pass filter using Butterworth filter. it gave me smooth signal in the time domain. Now when I'm trying to apply the butterworth band pass filter between frequencies (630 Hz to 640 Hz) its not working properly. I don't know  if I'm doing it right. 
  The following picture is after the application of low pass filter ( butterworth).</p>
  
  <p><img src="https://i.stack.imgur.com/jF8nm.jpg" alt="enter image description here"></p>
  
  <p>This is another after I applied butterworth low pass and band pass filters. There is complete change in the original signal.</p>
  
  <p><img src="https://i.stack.imgur.com/xX2S5.jpg" alt="enter image description here">
  I'm expecting the filter to do something like this a cleaner orbit for 1X frequency component.</p>
  
  <p><img src="https://i.stack.imgur.com/5w6AT.jpg" alt="enter image description here"></p>
  
  <p>My MATLAB code is as follows.</p>
  
  <pre><code>  L = length(X); % length of signal
    fs= 2e6; % sampling frequency
    df = fs/L; % Frequency window
    dt = 1/df; % time window
    %calculate time axis
    T = (0:dt:(L-1)*dt)';
    subplot(3,2,1);
    plot(T,X);
    title('before filtering X signal')
    subplot (3,2,2);
    plot(T,Y);
    title('before filtering Y signal')
    subplot(3,2,5);
    plot(X,Y);
    title('Orbits before filtering')
    X = detrend(X,0); % Removing DC Offset
    Y = detrend(Y,0); % Removing DC Offset
  
    % Butterworth low pass filter to remove high frequency components
    [b2,a2] = butter(6,5*633/(fs/2),'low');
    dataInX = X; 
    X = filter(b2,a2,dataInX); %filter command filters 
    dataInY = Y;
    Y = filter(b2,a2,dataInY);
  
    % butter worth band pass to only plot for 1X frequency component
    [b1,a1] = butter(1,[633/(fs/2) 640/(fs/2)],'bandpass');
    dataInX = X; 
    X = filter(b1,a1,dataInX); %filter command filters 
    dataInY = Y;
    Y = filter(b1,a1,dataInY);
  
    subplot(3, 2 ,3);
    plot(T,X);
    axis tight
    title('X signal after filtering')
    subplot(3,2,4);
    plot(T,Y);
    axis tight
    title('Y signal after filtering')
    subplot(3,2,6);
    plot(X,Y);
    title('Orbit after filtering')
    axis tight
  </code></pre>
  
  <p>I'm also attaching my <a href="https://drive.google.com/file/d/0Byib6yrCQ9vnTWg4ZHJWRU1NdkU/view?usp=sharing" rel="nofollow noreferrer">data file</a> for reference. </p>
  
  <p>I'm new into the world of filters and DSP. Could someone help to fix this one with suggestions or hints or ideas. </p>