clear all
close all

load('transient_oscillations.mat')

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

fs=1/dt
order = 4

fmin=0.1
fmax=2.1
df=0.1
imax=floor((fmax-fmin)/df)

PP=zeros(imax,n);
freq=zeros(imax,1);

for i = 1:imax
    meanFreq=fmin+(i-1)*df;
    freq(i)=meanFreq;
    lowFreq=meanFreq-df/2;
    hiFreq=meanFreq+df/2;
    [b,a] = butter(order, [lowFreq hiFreq]/(fs/2), 'bandpass');
    PP(i,:) = abs(filtfilt(b,a,final));
end

t0=0;
T0=0.0;
t1=n;% number of points
T1=n*dt; % in seconds

logPP=10*log10(PP);
minPP=min(squeeze(min(PP)))
maxPP=max(squeeze(max(PP)))
minlogPP=min(squeeze(min(logPP)));
maxlogPP=max(squeeze(max(logPP)));
%pcolor(squeeze(time),freq,logPP');
pcolor(t(:,1),freq(:,1),PP);
% %imagesc(squeeze(data_1(:,1)),freq,10*log10(PP));
view(0,90);
%caxis([minlogPP,maxlogPP]);shading flat;
caxis([minPP,maxPP]);shading flat;
%caxis([20,maxlogPP]);shading flat;
%caxis([1.0e+02,2.0e+06]);shading flat;
axis([T0,T1,fmin,fmax-df]);
colorbar();
ylabel('frequency')
xlabel('time [s]')

