Skip to content

Commit 5751558

Browse files
committed
plotting power spectrum using pwelch instead of periodogram to increase peak height
1 parent 3636c91 commit 5751558

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

Analysis/SK/Scripts-in-progress/sinePDpowerspec.m renamed to Analysis/SK/Scripts-in-progress/SinePowerSpec.m

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@
4040

4141
for iFreq = 1:length(theseRecs)
4242
try thisRec = theseRecs{iFreq}(theseSizes(iFreq,1):theseSizes(iFreq,2),:);
43-
[pxx,f] = periodogram(thisRec,[],[],sf);
43+
%use pwelch instead of periodogram to allow for use of Hamming
44+
%window (reduces variance but decreases peak resolution/increases peak width)
45+
%alternatively, periodogram with shorter window (or full-length
46+
%hamming window to reduce edge effects?)
47+
[pxx,f] = pwelch(thisRec,5000,[],[],sf);
4448
allF = [allF mean(f,2)];
4549
allPSD = [allPSD mean(pxx,2)];
4650
allSize = [allSize theseSizes(iFreq,3)];
@@ -64,12 +68,13 @@
6468
meansByFreq (:,iProfile) = mean(thesePSD,2);
6569
end
6670

67-
plot(meanF,10*log10(meansByFreq));
71+
plot(meanF,meansByFreq);
72+
set(gca, 'YScale', 'log', 'XScale', 'log');
73+
6874
xlabel('frequency (Hz)');
69-
ylabel('dB');
75+
ylabel('A^2');
7076
legend(num2str(eachFreq'));
7177
box off;
72-
% plotfixer;
73-
7478
chH = get(gca,'children');
75-
set(gca,'children',flipud(chH));
79+
set(gca,'children',flipud(chH));
80+
plotfixer;

0 commit comments

Comments
 (0)