Method to Correlate Time Series Arrays of Differing Lengths
Mostrar comentarios más antiguos
I am attempting to correlate the time series from 4 separate tilt monitors that sample every 5 minutes. The time series have slightly different base times and end times, and the resulting arrays are slightly different lengths, though they span almost the (differing by ~3 mins) same period of time. My goal is to correlate each of these time series with a single "wind speed" time series that also covers the same period of time as the tilt monitors, sampling every 5 minutes, but also has a slightly different array length and origin time and end time.
The different array lengths in the tilt measurements are due to instrument error. There are some times within each of the arrays where the instrument missed a measurement and so the sample interval is 10 minutes.
My arrays sizes look something like this:
Tilt_a = 6236x2
Tilt_b = 6310x3
Tilt_c = 6304x2
Tilt_d = 6309x2
wind_Speed = 6383x2
I imagine that I will need to re-sample the data using something like interp1, but I do not know how to renconcile the origin and end times. Is there a method that comes to mind for handling a situation such as this one? Or a function that allows correlating arrays of differing lengths?
Respuesta aceptada
Más respuestas (1)
David Wilson
el 9 de Abr. de 2019
Editada: David Wilson
el 9 de Abr. de 2019
OK, I'll generate some fake data that is not aligned, and the do the above approach.
%% Generate some data series that are slightly off shifted
Ts = 5; % 5 min sample time
ta = [0:5:1000]'; ya = sin(ta/100);
tb = [2.7:5:1055]'; yb = sin(tb/100 + 0.3);
tc = [-25:5:998]'; yc = sin(tc/100 - 5);
plot(ta, ya,'.', tb, yb, 'x', tc, yc, 's')
You can see that the 3 time series are not aligned, and have (slightly) different start and end times.
% Now find latest common starting time
t0 = max([ta(1), tb(1), tc(1)]);
tfinal = min([ta(end), tb(end), tc(end)]);
ti = [t0:Ts:tfinal]';
In this case, I retain the sample time of 5 mins, but start at the latest start time (t=2.7) and finish at earliest finish time (t=995). This is to ensure we don't go over the end of the data sets, although we could use the 'extrapolate' option in interp1.
Now we interp1 for each of the 3 series.
yai = interp1(ta,ya,ti);
ybi = interp1(tb,yb,ti);
yci = interp1(tc,yc,ti);
plot(ti,[yai, ybi, yci])
cov([yai,ybi, yci])
You will note that the covariance calculation now works.
Categorías
Más información sobre Multirate Signal Processing en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!