Trying to merge two tables, using time stamps as keys in outerjoin(), getting 'incorrect data type or missing argument' error.
조회 수: 6 (최근 30일)
이전 댓글 표시
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
답변 (2개)
Xiaotao
2024년 5월 22일
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
Abhas
2024년 5월 22일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!