clear all
close all

load('transient_oscillations.mat')

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

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

subplot(2,1,2)
% compute FT
num_windows=2;
num_window_points=n/num_windows
duration_window=duration/num_windows
fs=1/dt;
overlap=0
window = rectwin(num_window_points);


[S,F,T,P]=spectrogram(final,window,overlap,num_window_points,fs);
%T
%Pt=P'
pcolor(T,F,10*log10(P));
%plot(10*log(Pt(1,:)))
Pmax=max(max(P))
Pmin=min(min(P))
Tmax=max(max(T))
Tmin=min(min(T))
view(0,90);
caxis([-5,Pmax]);shading flat;
axis([Tmin,Tmax,0,2.0]);
colorbar();
ylabel('frequency')
xlabel('time [s]')

