function [freq, P]=fft_func(p,dt)
% calculates FFT of given signal
% p= signal wave form
% dt= time step

nsamp   = length(p); %length of signal
NFFT=nsamp;
P=fft(p,NFFT);  % FFT of signal
P=dt*P(1:NFFT/2+1); % pozitive frequencies and normalization
freq = (0.5/dt)*linspace(0,1,NFFT/2+1); % frequency vector

end
