フィルターのクリア

Correlation of similar Signals

1 回表示 (過去 30 日間)
Sam Hurrell
Sam Hurrell 2022 年 11 月 17 日
回答済み: Mathieu NOE 2022 年 11 月 18 日
I have 2 signals on the same time axis: an ideal signal and the actual signal received. I have used the 'xcorr' function for these signals and produced a graph (as per the MATLAB help centre for xcorr), but I don't understand how this answers how closely correlated these signals are at any given time. What I'd like is to produce a graph of correlation coefficient for both signals across time, rather than an overall value as 'corrcoef'. How can this be done, or should I use the corrcoef function for sections in time rather than overall?

採用された回答

Mathieu NOE
Mathieu NOE 2022 年 11 月 18 日
hello
maybe this ?
define a buffer lenth and an overlap (here I took the max possible overlap) and use corrcoef (take the non diagonal term)
% dummy data
n=1000;
t= 1:n;
x = sin(8*pi*t./max(t))+0.1*rand(1,n);
y = sin(8*pi*t./max(t)+0.25)+0.5+0.1*rand(1,n);
mybuffer = 100; % nb of samples in one buffer (buffer size)
overlap = mybuffer-1; % overlap expressed in samples
%%%% main loop %%%%
m = length(x);
shift = mybuffer-overlap; % nb of samples between 2 contiguous buffers
for ci=1:fix((m-mybuffer)/shift +1)
start_index = 1+(ci-1)*shift;
stop_index = min(start_index+ mybuffer-1,m);
time_index(ci) = floor((start_index+stop_index)/2); % time index expressed as sample unit (dt = 1 in this simulation)
M = corrcoef(x(start_index:stop_index),y(start_index:stop_index));
corcoefficient(ci) = M(2,1);
end
t2 = t(time_index);
figure(1),
plot(t,x,t,y,t2,corcoefficient,'-+r');
legend('signal x ','signal y ','cor coefficient');

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCorrelation and Convolution についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by