clear all
close all

load('transient_oscillations.mat')

% generate data example
duration = max(t);
n = duration / dt+1
fmax=1/dt;
df=1/duration;

ratio=0.2
L=duration*ratio
n_L = floor(n*ratio)
n_dL=floor(n*(1.0-ratio)/2)

final_short=zeros(1,n);

% zero padding
for j = n_dL:n-n_dL
   final_short(j)=final(j) ;
end

figure(1)
subplot(2,1,1)
plot(t,final,t,final_short,'r');
xlabel('time')
ylabel('data')

subplot(2,1,2)
% compute FT
ft=fft(final);
ft_short=fft(final_short);
freq = linspace(0,fmax/2,n/2);
n_maxf=2.0/df;
plot(freq(1:n_maxf),abs(ft(1:n_maxf)),freq(1:n_maxf),abs(ft_short(1:n_maxf)),'r');
xlabel('frequency')
ylabel('amplitude power')


