Shifting table entries based on criteria
Afficher commentaires plus anciens
Hi, I've realized the tables in MAtlab is very powerful, but I've just started using it and so far it isn't very intuitive. This may be a simple question, but it's not obvious to me. Hope someone will help. I have two tables, T1 and T2. They each have a time variable, T1.time and T2.time. And each has a Y variable, T1.Y and T2.Y.
When the Y variables are plotted in a scatter plot, they look like this:

Notice that T1.Y (green) is shifted by some number of time units to the left of T2.Y (red). I would like to find the number of time units and shift T1.Y to the right, so they are alinged, and then I can compute a correlation coefficient.
My thought is to find the maximum of T1.Y(i+3) - T1.Y(i) and T2.Y(i+3) - T2.Y(i) and return these indices. One might be at i = 105 (green) and the other might be i = 140 (red) for example. So the difference is 35 time segments. I can then add 35 time segments to the T1.time, and if replotted they should be aligned. And then I can compute the correlation?
First question, does this 'algorithm' make sense for alignment? And secondly, using the table variables, any suggestion how I might find the shift required and the index for for the shift (i.e. at what index value does the green plot have a large change, at which index value does the red plot have a large change). Does this make sense? I'm using R2018b.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Array Geometries and Analysis dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!