필터 지우기
필터 지우기

Cross-correlation plots and find the median

조회 수: 2 (최근 30일)
Chi Pham
Chi Pham 2019년 10월 30일
답변: Subhadeep Koley 2019년 11월 4일
I have 2 sets of data and I want to find the cross-correlation between them and plot it out. I want to first plot each of the trace and then find the median cross-correlation. However, I have not been able to do so. Here is my code.
figure
for i=1:26
subplot(3,9,i)
[c,lags] = xcorr(dataA(i), dataB(i));
stem(lags,c)
xlabel('lag')
ylabel('Cross-correlation')
end

답변 (1개)

Subhadeep Koley
Subhadeep Koley 2019년 11월 4일
I assume that you are trying to find the median value for each of the cross-correlation vector and plot them along with the cross-correlation plot. The below code might help.
clear;clc;close all;
load data.mat
figure('units','normalized','outerposition',[0 0 1 1])
for i=1:26
subplot(3,9,i)
[c,lags] = xcorr(cell2mat(dataA(i)), cell2mat(dataB(i)));
c_median = median(c); % Finding the median correlation
stem(lags,c);
hold on;
plot(c_median,'ro','MarkerSize',8,'MarkerFaceColor','red')
xlabel('lag')
ylabel('Cross-correlation')
legend('Correlation','Median')
end
corr_median.png

카테고리

Help CenterFile Exchange에서 Correlation and Convolution에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by