Trying to merge two tables, using time stamps as keys in outerjoin(), getting 'incorrect data type or missing argument' error.
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi!
I have two tables, each with two rows. One is 'raw', and has each possible time stamp and corresponding data. The other is 'valid', and only has time stamps corresponding to valid data. I want to have a third table, that contains all time stamps but NaNs where there isn't both raw and valid data.
So, for example, these would go into outerjoin()
valid = 't_ms' 'val_dat'
[ 1 55
2 50
4 52 ]
raw = [ 1 49
2 37
3 51
4 52 ]
And I'd get a table that's the length of 'raw', and 'valid' containing NaNs. Instead, I get the error:
'Check for incorrect argument data type or missing argument in call to outerjoin.'
I've quadruple checked that I'm inputting tables, and the key variables have the exact same name, and I've tried pretty much every optional argument into outerjoin() I can, no dice.
Any help would be much appreciated, embarrassingly enough I'm stumped!
Thanks
0 commentaires
Réponses (2)
Xiaotao
le 22 Mai 2024
valid = table([1;2;4],[55 50 52]', 'VariableNames',{'t_ms','val_dat'});
raw = table([1;2;3;4],[49 37 51 52]', 'VariableNames',{'t_ms','raw_dat'});
third = outerjoin(valid, raw,'MergeKeys',true)
0 commentaires
Abhas
le 22 Mai 2024
Hi Tyler,
MATLAB's "outerjoin" function can be used with "MergeKeys" arguments to fill the missing values with NaNs where there is no match.
Here's the MATLAB code to perform the required steps:
% Define the 'valid' table
valid = table([1; 2; 4], [55; 50; 52], 'VariableNames', {'t_ms', 'val_dat'});
% Define the 'raw' table
raw = table([1; 2; 3; 4], [49; 37; 51; 52], 'VariableNames', {'t_ms', 'raw_dat'});
% Perform the outer join
result = outerjoin(raw, valid, 'Keys', 't_ms', 'MergeKeys', true)
The "result" variable stores the "outerjoin" of the two tables.
You may refer to the following documentation link to have a better understanding on joins:
0 commentaires
Voir également
Catégories
En savoir plus sur Tables 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!