Main Content

두 신호의 주파수 성분 비교하기

스펙트럼 코히어런스는 주파수 영역에서 신호 간의 유사성을 확인하는 데 유용합니다. 값이 크면 신호 간에 공통적인 주파수 성분이 있음을 나타냅니다.

두 소리 신호를 작업 공간으로 불러옵니다. 신호는 1kHz로 샘플링됩니다. periodogram을 사용하여 신호의 파워 스펙트럼을 계산하고 나란히 플로팅합니다.

load relatedsig

Fs = FsSig;

[P1,f1] = periodogram(sig1,[],[],Fs,'power');
[P2,f2] = periodogram(sig2,[],[],Fs,'power');

subplot(2,1,1)
plot(f1,P1,'k')
grid
ylabel('P_1')
title('Power Spectrum')

subplot(2,1,2)
plot(f2,P2,'r')
grid
ylabel('P_2')
xlabel('Frequency (Hz)')

Figure contains 2 axes objects. Axes object 1 with title Power Spectrum, ylabel P_1 contains an object of type line. Axes object 2 with xlabel Frequency (Hz), ylabel P_2 contains an object of type line.

각 신호에는 상당한 에너지를 가진 3개의 주파수 성분이 있습니다. 이 성분 중 두 개는 공유되는 것으로 보입니다. findpeaks를 사용하여 이 주파수를 찾습니다.

[pk1,lc1] = findpeaks(P1,'SortStr','descend','NPeaks',3);
P1peakFreqs = f1(lc1)
P1peakFreqs = 3×1

  165.0391
   35.1562
   94.7266

[pk2,lc2] = findpeaks(P2,'SortStr','descend','NPeaks',3);
P2peakFreqs = f2(lc2)
P2peakFreqs = 3×1

  165.0391
   35.1562
  134.7656

공통 성분은 165Hz와 35Hz 근방에서 나타납니다. mscohere를 사용하여 일치하는 성분을 직접 찾을 수 있습니다. 코히어런스 추정값을 플로팅합니다. 임계값 0.75를 넘는 피크를 찾습니다.

[Cxy,f] = mscohere(sig1,sig2,[],[],[],Fs);

thresh = 0.75;
[pks,locs] = findpeaks(Cxy,'MinPeakHeight',thresh);
MatchingFreqs = f(locs)
MatchingFreqs = 2×1

   35.1562
  164.0625

figure
plot(f,Cxy)
ax = gca;
grid
xlabel('Frequency (Hz)')
title('Coherence Estimate')
ax.XTick = MatchingFreqs;
ax.YTick = thresh;
axis([0 200 0 1])

Figure contains an axes object. The axes object with title Coherence Estimate, xlabel Frequency (Hz) contains an object of type line.

앞부분에서 얻은 값과 동일한 값을 얻었습니다. 두 신호를 별개로 분석하지 않고도 두 신호 간에 공통적인 주파수 성분을 찾을 수 있습니다.

참고 항목

| |

관련 항목