%render 2 suplots - view of 320 samples and FFT of it
%inspired by Matlab help example
%source:    http://www.mathworks.com/help/matlab/ref/fft.html
function fftr = fftr(tim, data,Fs, i)
figure(i);
% plot series of samples
 subplot(2,1,1);
 [AX] = plot(tim,data);
 title('Pole vzorků');
 xlabel('t (s)');
 ylabel('a (ms^{-2})');
 grid on;
 % graphical modifications
 set(get(get(AX, 'Parent'), 'XLabel'),'FontSize',16);
 set(get(get(AX, 'Parent'), 'YLabel'), 'FontSize',16);
 set(get(AX, 'Parent'), 'FontSize',14);
 set(get(get(AX, 'Parent'), 'Title'), 'FontSize', 16);
 %********************


L = length(data);
NFFT = 2^nextpow2(L); % Next power of 2 from length of y
Y = fft(data,NFFT)/L;
f = Fs/2*linspace(0,1,NFFT/2+1);

% Plot single-sided amplitude spectrum.
subplot(2,1,2)
[AX] = plot(f,2*abs(Y(1:NFFT/2+1))) 
title('Amplitudové spektrum')
xlabel('f (Hz)')
ylabel('|Y(f)|')
grid on;
% graphical modifications
set(get(get(AX, 'Parent'), 'XLabel'),'FontSize',16);
set(get(get(AX, 'Parent'), 'YLabel'), 'FontSize',16);
set(get(get(AX, 'Parent'), 'Title'), 'FontSize', 16);
set(get(AX, 'Parent'), 'FontSize',14);
%********************