close all
clear all
clc

lab4_raw_impulse_data

T = Raw_Data(3,2)-Raw_Data(2,2);                     % Sample time
Fs = 1/T;                    % Sampling frequency


figure1 = figure('PaperType','<custom>','PaperSize',[15.5 10],...
                    'InvertHardcopy','off',...
                    'Color',[1 1 1]);

axes1 = axes('Parent',figure1,'YGrid','on','XGrid','on',...
                'Units','centimeters',...
                'Position',[1.5 1.5 12.5 9],...
                'MinorGridLineStyle','--',...
                'GridLineStyle','-',...
                'FontSize',8,...
                'FontName','times new roman');
box(axes1,'on');
hold(axes1,'all');
    
    for i=1:3
       YData = Raw_Data(:, 3+i);
       YData(1)
       L = length(YData); 
       NFFT = 2^nextpow2(L);
       
       dummy = fft(YData.*hann(L),NFFT)/L;       
       Y(1, 1:NFFT/2+1) = 2*abs(dummy(1:NFFT/2+1));
       f(1, 1:NFFT/2+1) = Fs/2*linspace(0,1,NFFT/2+1);   
       
        plot(f(1, 1:round(L/5)), Y(1, 1:round(L/5)), ...
                'Parent',axes1, ...
		'Marker','none', ...
		'LineWidth',1);
 
    end
         
	xlabel('Frequency (Hz)','FontSize',10,'FontName','times new roman');
	ylabel('Encoder Position','FontSize',10,'FontName','times new roman');
    legend('Encoder 1','Encoder 2','Encoder 3');
