Can I specify the variable name to use as a key when I use innerjoin() or does it have to be a column number?

3 views (last 30 days)
Can I use innerjoin(A,B,'Keys','Date') or do I have to use innerjoin(A,B,'Keys'1) when innerjoining two tables which have a commom first colunn called Date (with datetime variables)? Is there any advantage or disadvantage to doing it one way or the other?

Accepted Answer

Guillaume
Guillaume on 30 Oct 2017
Edited: Guillaume on 30 Oct 2017
It's all very well documented. keys can be a positive integer index, a vector of positive integer indices, a character vector of the name of the column, a cell array of character vectors of the names of the column or a logical vector.
It's the same syntax you use to refer to any column of a table, which is all explained in access data in a table.
There may be a negligible speed difference between the methods but nothing worth worrying about. As it's not documented, this could change from version to version. So, use whichever method is more convenient for you.
edit: of course, using numeric or logical indexing means that the key(s) must be the same column index(es) in both tables. With a char array or cell array of char arrays they don't have to be.

More Answers (0)

Categories

Find more on Dates and Time in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!