How to align multiple datasets but data are not totally identical

17 vues (au cours des 30 derniers jours)
Rocio Navarro
Rocio Navarro le 16 Mai 2022
Hi, I'm new to Matlab and I have some questions regarding data alignment. I've seen similar questions already, like this one:
https://es.mathworks.com/matlabcentral/answers/429858-how-to-align-multiple-datasets
So in my case I also want to align two datasets but values are not totally similar, so I would like to know if there is a script that allows me to align datasets but adding some relative deviation. For example, I want to align values of 13.0 with values ranging from 12.5 to 13.5 (13.0+-0.5). Is this possible?
Thank you very much in advance
  2 commentaires
Image Analyst
Image Analyst le 16 Mai 2022
What form are your data in? Like a set of (x,y,z) point coordinates? Did you try a web search for "point set matching"
Rocio Navarro
Rocio Navarro le 16 Mai 2022
My data are in tables of 3 columns. One of the columns have values ranging from 100 to 1000 but they are not identical, they can vary in a 0.05 value and I would like to know how to tell the program that I admit this variation (for example, that I want to consider 100.00 and 100.05 as the same value.

Connectez-vous pour commenter.

Réponses (1)

Abhijit Bhattacharjee
Abhijit Bhattacharjee le 19 Mai 2022
Without seeing a bit more detailed of an example, it's not easy to recommend the best path forward. But you could consider creating a copy of your data with rounded or binned values that you use for alignment, and then use the aligned indices to recover the original data of the alignment.
Here's a quick example:
% create example arrays to be aligned
idx1 = [1 2 3.05 3.95 5]';
idx2 = [2 3.01 4.03]';
A = array2table([idx1, randn(size(idx1))])
A = 5×2 table
Var1 Var2 ____ ________ 1 -2.4681 2 0.63173 3.05 1.2528 3.95 1.1205 5 -0.41651
B = array2table([idx2, randn(size(idx2))])
B = 3×2 table
Var1 Var2 ____ _______ 2 -1.0419 3.01 0.15861 4.03 -0.7413
% round the arrays
idx1_rounded = round(idx1);
idx2_rounded = round(idx2);
A_rounded = A;
A_rounded.Var1 = idx1_rounded
A_rounded = 5×2 table
Var1 Var2 ____ ________ 1 -2.4681 2 0.63173 3 1.2528 4 1.1205 5 -0.41651
B_rounded = B;
B_rounded.Var1 = idx2_rounded
B_rounded = 3×2 table
Var1 Var2 ____ _______ 2 -1.0419 3 0.15861 4 -0.7413
% align the arrays
result = outerjoin(A_rounded, B_rounded, 'Keys', [1,1])
result = 5×4 table
Var1_A_rounded Var2_A_rounded Var1_B_rounded Var2_B_rounded ______________ ______________ ______________ ______________ 1 -2.4681 NaN NaN 2 0.63173 2 -1.0419 3 1.2528 3 0.15861 4 1.1205 4 -0.7413 5 -0.41651 NaN NaN

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Produits


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by