Main Content

このページの内容は最新ではありません。最新版の英語を参照するには、ここをクリックします。

測定データ内の信号の検出

データを受信し、それが測定済みのより長いストリームに一致するかどうかを知る必要があるとします。データがノイズで破損している場合でも、相互相関ではこの判定を行うことができます。

卓上で回転するリングの録音データをワークスペースに読み込みます。1 秒分のフラグメントを切り取り、聴いてみましょう。

load('Ring.mat')

Time = 0:1/Fs:(length(y)-1)/Fs; 

m = min(y);
M = max(y);

Full_sig = double(y);

timeA = 7;
timeB = 8;
snip = timeA*Fs:timeB*Fs;

Fragment = Full_sig(snip);

% To hear, type soundsc(Fragment,Fs)

信号とフラグメントをプロットします。参考として、フラグメントの終点を強調表示してみます。

plot(Time,Full_sig,[timeA timeB;timeA timeB],[m m;M M],'r--')
xlabel('Time (s)')
ylabel('Clean')
axis tight

Figure contains an axes object. The axes object with xlabel Time (s), ylabel Clean contains 3 objects of type line.

plot(snip/Fs,Fragment)
xlabel('Time (s)')
ylabel('Clean')
title('Fragment')
axis tight

Figure contains an axes object. The axes object with title Fragment, xlabel Time (s), ylabel Clean contains an object of type line.

完全な信号およびフラグメントの相互相関を計算し、プロットします。

[xCorr,lags] = xcorr(Full_sig,Fragment);

plot(lags/Fs,xCorr)
grid
xlabel('Lags (s)')
ylabel('Clean')
axis tight

Figure contains an axes object. The axes object with xlabel Lags (s), ylabel Clean contains an object of type line.

相互相関が最大になる遅れは、各信号の開始点の間の時間遅延です。信号を再プロットし、フラグメントを重ね合わせます。

[~,I] = max(abs(xCorr));
maxt = lags(I);

Trial = NaN(size(Full_sig));
Trial(maxt+1:maxt+length(Fragment)) = Fragment;

plot(Time,Full_sig,Time,Trial)
xlabel('Time (s)')
ylabel('Clean')
axis tight

Figure contains an axes object. The axes object with xlabel Time (s), ylabel Clean contains 2 objects of type line.

手順を繰り返します。ただし、ノイズを信号とフラグメントに別々に追加します。音声はノイズから抽出することはできません。

NoiseAmp = 0.2*max(abs(Fragment));

Fragment = Fragment+NoiseAmp*randn(size(Fragment));

Full_sig = Full_sig+NoiseAmp*randn(size(Full_sig));

% To hear, type soundsc(Fragment,Fs)

plot(Time,Full_sig,[timeA timeB;timeA timeB],[m m;M M],'r--')
xlabel('Time (s)')
ylabel('Noisy')
axis tight

Figure contains an axes object. The axes object with xlabel Time (s), ylabel Noisy contains 3 objects of type line.

ノイズ レベルが高い場合でも、次の手順により欠損フラグメントが検出されます。

[xCorr,lags] = xcorr(Full_sig,Fragment);

plot(lags/Fs,xCorr)
grid
xlabel('Lags (s)')
ylabel('Noisy')
axis tight

Figure contains an axes object. The axes object with xlabel Lags (s), ylabel Noisy contains an object of type line.

[~,I] = max(abs(xCorr));
maxt = lags(I);

Trial = NaN(size(Full_sig));
Trial(maxt+1:maxt+length(Fragment)) = Fragment;

figure
plot(Time,Full_sig,Time,Trial)
xlabel('Time (s)')
ylabel('Noisy')
axis tight

Figure contains an axes object. The axes object with xlabel Time (s), ylabel Noisy contains 2 objects of type line.

参考

関連するトピック