# Pad ratio

[原文](http://bishoptechbits.blogspot.ie/2010/07/simplified-introduction-to-time.html)

## Pad ratio

### Why? To improve frequency resolution

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');
```

![](https://1237447543-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4ZaszQkuLof2XL0b_v%2F-M4Zav0QOp8dmT2IkJTc%2F-M4Zb1c77ro6E4o5ZVND%2F10-1.png?generation=1586530896859388\&alt=media)

### 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
```

![](https://1237447543-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4ZaszQkuLof2XL0b_v%2F-M4Zav0QOp8dmT2IkJTc%2F-M4Zb1c9dZ-2Eyg2-VYP%2F10-2.png?generation=1586530897004064\&alt=media) ![](https://1237447543-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4ZaszQkuLof2XL0b_v%2F-M4Zav0QOp8dmT2IkJTc%2F-M4Zb1cBH-jSQLVm5Kau%2F10-3.png?generation=1586530897452600\&alt=media) ![](https://1237447543-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4ZaszQkuLof2XL0b_v%2F-M4Zav0QOp8dmT2IkJTc%2F-M4Zb1cDe84jtTplmar8%2F10-4.png?generation=1586530902509795\&alt=media) ![](https://1237447543-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4ZaszQkuLof2XL0b_v%2F-M4Zav0QOp8dmT2IkJTc%2F-M4Zb1cFF-OmSXU3GgHB%2F10-5.png?generation=1586530896623916\&alt=media) ![](https://1237447543-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4ZaszQkuLof2XL0b_v%2F-M4Zav0QOp8dmT2IkJTc%2F-M4Zb1cHRbK6cE3woeok%2F10-6.png?generation=1586530897630532\&alt=media) ![](https://1237447543-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4ZaszQkuLof2XL0b_v%2F-M4Zav0QOp8dmT2IkJTc%2F-M4Zb1cJvLhWcqs_aMRi%2F10-7.png?generation=1586530897239398\&alt=media)
