Conduct the cross-correlation analysis for the two sets of the data with different time lags and find the maximum correlation coefficient and the corresponding time-lag.
7 views (last 30 days)
Show older comments
Conduct the cross-correlation analysis for the two sets of the data with different time lags and find the maximum correlation coefficient and the corresponding time-lag.
my data is WS_40 and WS_20 (speed)
crosscorr=xcorr(a,c);
[r,lags] = xcorr(a,c);
figure(7)
plot(lags,r)
Is it right?
But I still do not know how to find the maximum correlation coefficient and the corresponding time-lag
0 Comments
Answers (1)
Mathieu NOE
on 15 May 2021
hello
here you are
all the best
T = readtable('wind data set no 3.xlsx');
C = table2cell(T);
a = cell2mat(C(4:end,3));
c = cell2mat(C(4:end,4));
% crosscorr=xcorr(a,c);
[r,lags] = xcorr(a,c,'normalized');
figure(7)
plot(lags,r)
[val,ind] = max(r);
lag = lags(ind); % lag in samples (here 3 samples = 3 seconds as we collect data every second)
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!