フィルターのクリア

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 Center および File ExchangeCorrelation and Convolution についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by