%% Controlling the padding

display('To compute spectrum with more padding, press enter');
pause
%
% First recompute spectrum with defaults
ch=6;% trial number
delay_samples=1001:2000; % delay period sample numbers
data=dlfp1t(delay_samples,ch); % data in delay period
params.Fs=1000; % sampling frequency
params.fpass=[0 100]; % frequency range of interest
[S,f]=mtspectrumc(data,params);
plot_vector(S,f,[],[],'y'); 
set(gca,'FontName','Times New Roman','Fontsize', 16);
xlabel('frequency Hz'); ylabel('Spectrum dB');
title('LFP spectrum for 1 trial for two pads (NFFT=1024 (yellow), NFFT=4096 (magenta))');
position_figure
%
% Compute spectrum with higher padding
%
ch=6;% trial number
delay_samples=1001:2000; % delay period sample numbers
data=dlfp1t(delay_samples,ch); % data in delay period
params.Fs=1000; % sampling frequency
params.fpass=[0 100]; % frequency range of interest
params.pad=2; % set the pad factor
[S,f]=mtspectrumc(data,params);
%
% Plot over the current figure
%
hold on; % plot onto current figure
plot_vector(S,f,[],[],'m'); 
set(gca,'FontName','Times New Roman','Fontsize', 16);
xlabel('frequency Hz'); ylabel('Spectrum dB');
title('LFP spectrum for 1 trial for two pads (NFFT=1024 (yellow), NFFT=4096 (magenta))');
position_figure
