Pad ratio is another parameter that can be modified to select an analysis most suitable for identifying key features in your data. Padding is literally that – it involves adding zeros to your signal to make it longer, which improves frequency resolution.
Make complex signal with long and short bursts of power at 8 and 45 Hz
%-----------------------------------------------------------------------------------
% Make complex signal with long and short bursts of power at 8 and 45 Hz
%-----------------------------------------------------------------------------------
D = 2; %signal duration 2s
S = 1000; % sampling rate, i.e. N points pt sec used to represent sine wave
F = [8 8 45 45]; % 4 frequencies in Hz
w = 2*pi*F; % convert frequencies to radians
P = [0 0 0 0]; % 4 corresponding phases
T = 1/S; % sampling period, i.e. for this e.g. points at 1 ms intervals
t = [T:T:D]; % time vector %corrected from previous version
t=t(1:length(t)-1); % takes off extra point arising from starting at zero
nfreqs=length(F); % N frequencies in the complex
A=ones(nfreqs,length(t)); %amplitudes initialised at one
A(1,550:570)=3; %burst of increased amplitude at each time pt
A(2,700:900)=3;
A(3,950:970)=3;
A(4,1100:1300)=3;
% Add all sine waves together to give composite
for thispt=1:2000
for thisfreq=1:nfreqs
mysig(thisfreq,thispt) =A(thisfreq,thispt)*sin(w(thisfreq)*t(thispt));
end
end
mysig2=sum(mysig,1);
t=t-.5; %subtract 500 ms to indicate baseline is negative
figure; plot(t,mysig2);
xlabel('Time (seconds)');
ylabel('Amplitude');
scrsz = get(0,'ScreenSize');
Testing different pad ratio and save plots
n=1
for pr=[.5, 1,2,4,8,16] %pad ratio
n=n+1
cyc=[1 ]; % cycles (can experiment with different values)
fig=figure('Position',[1 scrsz(4)/4 scrsz(3)/2 scrsz(4)/3])
[ersp,itc,powbase,times,freqs]=...
newtimef( mysig2,2000,[-500 1500],1000, cyc, 'erspmax', 20, 'plotitc', 'off', 'padratio',pr);
title(strcat('Pad ratio= ',num2str(pr),': N freqs=',num2str(length(freqs))));
print(fig,['10-',num2str(n)],'-dpng')
end