필터 지우기
필터 지우기

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 CenterFile Exchange에서 Correlation and Convolution에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by