clear all
close all

load('transient_oscillations.mat')

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

fs=1/dt

coefs2 = cwt(final,1:100,'cmor1-1'); 
coefs1 = cwt(final,1:100,'morl'); 
coefs3 = cwt(final,1:100,'cgau1'); 

cfreq1=centfrq('morl')
cfreq2=centfrq('cmor1-1',10)
cfreq3=centfrq('cgau5',10)

scales=1:100;

freq2=zeros(100,1);
freq3=zeros(100,1);

%freq1=scal2frq(1:100,'morl',dt)
freq1=cfreq1./(scales*dt);
freq2=cfreq2./(scales*dt);
freq3=cfreq3./(scales*dt);

freq1max=max(freq1)
freq2max=max(freq2)
freq3max=max(freq3)
freq1min=min(freq1)
freq2min=min(freq2)
freq3min=min(freq3)

figure(1)
PP=abs(coefs1);
colormap jet; 
minPP=min(squeeze(min(PP)))
maxPP=max(squeeze(max(PP)))
pcolor(squeeze(t),freq1,PP);
view(0,90);
caxis([minPP,maxPP]);shading flat;
axis([1,100,freq1min,2.0]);
colorbar();
ylabel('frequency')
xlabel('time [s]')

figure(2)
PP=abs(coefs2);
colormap jet; 
minPP=min(squeeze(min(PP)))
maxPP=max(squeeze(max(PP)))
pcolor(squeeze(t),freq2,PP);
view(0,90);
caxis([minPP,maxPP]);shading flat;
axis([1,100,freq2min,2.0]);
colorbar();
ylabel('frequency')
xlabel('time [s]')

figure(3)
PP=abs(coefs3);
colormap jet; 
minPP=min(squeeze(min(PP)))
maxPP=max(squeeze(max(PP)))
pcolor(squeeze(t),freq3,PP);
view(0,90);
caxis([minPP,maxPP]);shading flat;
axis([1,100,freq3min,2.0]);
colorbar();
ylabel('frequency')
xlabel('time [s]')