how to align multiple datasets
40 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Felix Flores James
le 14 Nov 2018
Commenté : Khanyisile
le 23 Mar 2023
Hey guys,
I'm new to MATLAB so this might seem silly, but how could I align data-rows by value. So let's say I have a dataset A with N number of rows and one column (column#1), and I have a dataset B with N number of rows and two columns, denoted as column #2, and column #3. Column #1 of dataset A is used as an aligin-template with values ranging from 34 to 700 (in steps of 0.1). Now what I would like to do is pairing the data of column#2 with column #3 so that if column #2 gets aligned with column#1, column#3 will still maintain its position with respect to column#2.
I hope that I'm not confusing you guys, but basically what I want to do is align data by value without losing correlation between two columns
[edit]
maybe this example will clarify what I mean with aligning paired data. So I want to align column #2 with column#1, while column #2 stays paired with column #3. And maybe as an extra fill in 0 if there is no data, but I think I can figure that one out.
many thanks!
2 commentaires
Matt J
le 16 Mai 2022
Rocio Navarro's comment moved here:
Hi, regarding this question, I would have a similar one if you can help me with it. So I also want to align two datasets but in my case 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
Réponse acceptée
Matt J
le 15 Nov 2018
Modifié(e) : Matt J
le 15 Nov 2018
If you have A and B in table form, it's a one-line solution:
%% Build fake data
A=linspace(31,32,11).';
B=A([2,5,7,9]); B=[B,rand(size(B))];
A=array2table(A);
B=array2table(B);
%% Solution
>> result =outerjoin(A,B,'LeftKeys','A','RightKeys','B1')
result =
11×3 table
A B1 B2
____ ____ _______
31 NaN NaN
31.1 31.1 0.63236
31.2 NaN NaN
31.3 NaN NaN
31.4 31.4 0.09754
31.5 NaN NaN
31.6 31.6 0.2785
31.7 NaN NaN
31.8 31.8 0.54688
31.9 NaN NaN
32 NaN NaN
2 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Axis Labels 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!