clear all
close all

load('transient_oscillations.mat')

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

L=n/10;
w = hamming(L);

figure(1)
plot(w)

num_shift=10;
shifts=n/num_shift
prod=zeros(n,num_shift);

for kk = 1:num_shift
    k=(kk-1)*shifts+1
    for j = 1:n
        %j-k
        if j>k & j-k<=L
            prod(j,kk)=final(j)*w(j-k);
        end
    end
end

figure(2)
nmax=800
subplot(2,1,1)
plot(t(1:nmax),final(1:nmax),'b',t(1:nmax),prod(1:nmax,1),'k',t(1:L),w,'r')
ylabel('signal')
xlabel('time [s]')

subplot(2,1,2)
plot(t(1:nmax),final(1:nmax),'b',t(1:nmax),prod(1:nmax,2),'k',t(1+shifts:L+shifts),w(1:L),'r')
ylabel('signal')
xlabel('time [s]')

