Cross-correlation plots and find the median

3 Ansichten (letzte 30 Tage)
Chi Pham
Chi Pham am 30 Okt. 2019
Beantwortet: Subhadeep Koley am 4 Nov. 2019
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

Antworten (1)

Subhadeep Koley
Subhadeep Koley am 4 Nov. 2019
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

Kategorien

Mehr zu Particle & Nuclear Physics finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by