%% Compare Slepian and Sine Tapers
% Generate the first five Slepian tapers corresponding to a time-halfbandwidth product of 3. Specify a taper length of 1000.

N = 1000;
nw = 3;
ns = 2*(nw)-1;

tprs = dpss(N,nw,ns);
lbs = "Slepian";

%
% Generate the first five sine tapers.

n = 1:N;
k = 1:ns;

tprs(:,:,2) = sqrt(2/(N+1))*sin(pi*n'*k/(N+1));
lbs(2) = "Sine";

%
% Plot the two sets of tapers.

for kj = 1:2
    subplot(2,1,kj)
    plot(tprs(:,:,kj))
    title(lbs(kj))
    legend(append('k = ',string(k)), ...
        'Orientation','horizontal','Location','south')
    legend('boxoff')
    ylim([-0.09 0.07])
end

% Copyright 2020 The MathWorks, Inc.