# Data vusualization - How to align data sets?

2 vues (au cours des 30 derniers jours)
Maria Perdomo le 14 Août 2013
Hallo,
I have two vectors. Each one contains data from two different devices wich measure the same periodic variable.
I would like to compare this two measurments sets without the aparent delay between them:
Is there a function in Matlab that could help to "align" the data sets? It would be actually enough to plot two periods.
Thank you.
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponse acceptée

Leah le 20 Août 2013
I would probably do the circshift function and search for the highest correlation. But if the first minimum works wells then stick with that.
Remember when you circshift that the values loop around so the the beginning of your time series (however many steps you shifted by) is not longer valid and should be removed from the analysis.
Here's a simple example of what I'm suggesting
series1=cos(0:.1:8*pi())';
series2=sin(0:.1:8*pi())';
plot(series2,'r')
hold on
plot(series1)
for t=1:64 % 64 is one period length
cm=corrcoef(series2,circshift(series1,t));
c(t)=cm(1,2);
end
[~,I] = max(c); % I is best value for circshift
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Plus de réponses (1)

the cyclist le 14 Août 2013
Are you trying to get MATLAB to figure how much to shift, or are you going to do that manually? If that latter, then you could probably just use the circshift() function.
##### 1 commentaireAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens
Maria Perdomo le 20 Août 2013
In the past, I had done it manualy, wrote a script to find withing a range the first minimum value from each vectors. Once located from the difference of their positions create a vector of with ceros that is used to shift the elements and discard the extra values left. If Matlab has a function to do this I would like to know.
Now, I think I can use the circshift() function to shift the values with out creating that vector full of zeros, may be thats a better way.
Thanks.

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Annotations dans Help Center et File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by