diff --git a/matlab/FFT_time2freq.m b/matlab/FFT_time2freq.m new file mode 100644 index 0000000..cdfad45 --- /dev/null +++ b/matlab/FFT_time2freq.m @@ -0,0 +1,9 @@ +function [f,val] = FFT_time2freq( t, val ) + +dt=t(2)-t(1); +val = [val zeros(1,5000)]; +L=numel(val); +f = (0:L-1)/L/dt; +f = f(1:floor(L/2)); +val = 2*fft(val)/L; +val = val(1:floor(L/2)); diff --git a/matlab/ReadUI.m b/matlab/ReadUI.m index 0d79a9e..bae9017 100644 --- a/matlab/ReadUI.m +++ b/matlab/ReadUI.m @@ -18,11 +18,5 @@ for n=1:numel(filenames) UI.TD{n}.t = t; UI.TD{n}.val = val; - dt=t(2)-t(1); - val = [val zeros(1,5000)]; - L=numel(val); - UI.FD{n}.f = (0:L-1)/L/dt; - UI.FD{n}.f = UI.FD{n}.f(1:floor(L/2)); - UI.FD{n}.val = 2*fft(val)/L; - UI.FD{n}.val = UI.FD{n}.val(1:floor(L/2)); + [UI.FD{n}.f,UI.FD{n}.val] = FFT_time2freq( t,val ); end