clear all
close all

load('transient_oscillations.mat')

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

n_short = 1134
t_short=t(1:n_short)
duration_short = max(t_short);
df_short=1/duration_short
final_short=final(1:n_short);

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

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

% subplot(3,1,3)
% % compute FT
% ft_short=fft(final_short);
% n_fmax_short=2.0/df_short;
% freq_short = linspace(0,fmax/2,n_short/2);
% plot(freq_short(1:n_fmax_short),abs(ft_short(1:n_fmax_short)))
% xlabel('frequency')
% ylabel('amplitude power')
