title: Signal division into parts on chart
body: <p>I have a signal from an interferometer, which is then filtered by FFT (fast Fourier transform) the filter itself works ok.
  For now i filter the signal in range which i choose, i can also do this in whole range, but i want cut this signal into parts and filter/analysis each parts, it can be done automaticly, or i can enter the range which i want. To cut this i must probably use some window ?</p>
  
  <p>The screenshot of the program:</p>
  
  <p><a href="https://i.stack.imgur.com/6eOm4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6eOm4.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/Syi5I.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Syi5I.png" alt="enter image description here"></a></p>
  
  <p>the link to the all files: <a href="https://drive.google.com/open?id=1GTQOJe53JGoIkdOxEIQY6TEpMoaSksxG" rel="nofollow noreferrer">here</a>, <a href="https://drive.google.com/open?id=1bTfrb2nRcvPfZrAKY9CSJEz13-TmDlOY" rel="nofollow noreferrer">here</a> and <a href="https://drive.google.com/open?id=15aOf1XSS9QIlUmUgkhHUWFQprAZWO6Yh" rel="nofollow noreferrer">here</a>.</p>
  
  <p><strong>My Code:</strong></p>
  
  <pre><code>clear all; 
  close all; 
  clc; 
  file_name = 'W0009.dat';
  [lam, I] = read_spectrum(file_name);
  lam = lam*1e-3;
  figure(1)
  plot(lam,I, '-k');hold on;
  
  mask = lam &gt;= 1.6 &amp; lam &lt;= 1.8;
  N = sum(mask);
  w = hamming(N);
  
  if mod(N, 2) == 0
      f = (-fix(N/2) : fix(N/2) - 1)/N; % czestotliwości dla N parzystego
  else
      f = (-fix(N/2) : fix(N/2))/N; % czestotliwości  dla N nieparzystego
  end
  
  F = 2*fftshift(fft(I(mask)))/N;
  W = fftshift(fft(I(mask).*w));
  
  m = abs(f) &lt;= 0.04;
  F(not(m)) = 0;
  
  figure(2)
  semilogy(f, abs(F), '-k');hold on;
  % semilogy(f, abs(W), '-r');hold on;
  
  fI = -abs(N*ifft(fftshift(F))/2);
  figure(3);
  plot(lam(mask), I(mask), '-k');hold on;
  plot(lam(mask), fI, '-r');
  
  % M = 258; b = fir1(M, 0.45);
  % I1 = I;
  % I1 = filter(b, 1, I1); I1(1 : end - floor(M/2)) = I1(floor(M/2) + 1 : end);
  % I1 = filtfilt(b, 1, I1);
  % plot(lam,I1);hold on;
  % 
  % M = 38; b = fir1(M, 0.15);
  % I2 = I;
  % I2 = filter(b, 1, I2); I2(1 : end - floor(M/2)) = I2(floor(M/2) + 1 : end);
  % I2 = filtfilt(b, 1, I2);
  % plot(lam,I2);hold on;
  % 
  % M = 52; b = fir1(M, 0.05);
  % I3 = I;
  % I3 = filter(b, 1, I3); I3(1 : end - floor(M/2)) = I3(floor(M/2) + 1 : end);
  % I3 = filtfilt(b, 1, I3);
  % plot(lam,I3);hold on;
  % 
  % fm1 = lam &lt; 1.8394 &amp; lam &gt; 1.5584;
  % Ifinal1 = I1(fm1);
  % fm2 = lam &gt; 1.8394 &amp; lam &lt; 1.98138;
  % Ifinal2 = I2(fm2);
  % fm3 = lam &lt; 2.216 &amp; lam &gt; 1.98138;
  % Ifinal3 = I3(fm3);
  % lamfinal = [lam(fm1);lam(fm2);lam(fm3)];
  % Ifinal = [Ifinal1;Ifinal2;Ifinal3];
  % close;
  % figure(2)
  % plot(lamfinal,Ifinal); hold on;
  % 
  % nlam = linspace(lamfinal(1), lamfinal(end), 9*length(lamfinal)).';
  % nI = interp1(lamfinal, Ifinal, nlam, 'spline');
  % plot(nlam,nI);
  % 
  % close;
  % figure(3)
  % [PKS1,LOCS1]= findpeaks(nI);
  % plot(nlam,nI);hold on;
  % plot(nlam(LOCS1),PKS1,'or'); hold on;
  % [PKS2,LOCS2]= findpeaks(-nI,'MinPeakWidth',25);
  % % PKS1 = [PKS1(1:73);PKS1(75:end)];
  % % LOCS1 = [LOCS1(1:73);LOCS1(75:end)];
  % % PKS2 = [PKS2(1:75);PKS2(77:end)];
  % % LOCS2 = [LOCS2(1:75);LOCS2(77:end)];
  % plot(nlam(LOCS2),-PKS2,'or');
  % axis tight;
  </code></pre>