plotting cross correlation to make the spectra align
이전 댓글 표시
I have a question about plotting. So I did a cross correlation using this code:
clear all; close all; clc
restoredefaultpath;
T5 = [21.68 21.99 21.84 22.58 21.85 21.79 21.35 21.37 21.42 22.24 22.29 22.28 22.04 22.33 21.99 23.14 22.84 21.70 19.94];
T6 = [21.8 18.6 20.8 21.4 21.7 21.4 21.2 21.3 21.2 21.1 21.1 22.2 22.0 20.6 20.7 20.8 20.4 20.3 20.5 20.5 20.0 20.2 20.6 20.2 20.0 20.3 20.1 20.3 20.2 19.9 20.2 20.7 20.1 20.5 19.6 20.4 20.5 20.2 20.5 20.3 20.4];
cor_seq = xcorr(T5,T6);
[cor_seq, lags] = xcorr(T5,T6);
f1 = figure;
plot(lags, cor_seq);
xlabel ('lag');
ylabel ('Correlation Measure');
xticks([-50 -45 -40 -35 -30 -25 -20 -15 -10 -5 0 5 10 15 20 25 30 35 40 45 50]);
grid on;
And I was wondering what code should I add to it to make it also plot the two time series with one alighning to the other at the lag they correlate the highest at?
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Correlation and Convolution에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!