Note: This page has been translated by MathWorks. Please click here

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Outer join between two tables or timetables

`C = outerjoin(A,B)`

`C = outerjoin(A,B,Name,Value)`

```
[C,ia,ib]
= outerjoin(___)
```

creates
the table or timetable, `C`

= outerjoin(`A,B`

)`C`

, as the outer join between `A`

and `B`

by
matching up rows using all the variables with the same name as key variables. You
can perform outer joins only on certain combinations of tables and
timetables.

If

`A`

is a table, then`B`

must be a table.`outerjoin`

returns`C`

as a table.If

`A`

is a timetable, then`B`

can be either a table or a timetable.`outerjoin`

returns`C`

as a timetable for either combination of inputs.

The outer join includes the rows that match between `A`

and `B`

,
and also unmatched rows from either `A`

or `B`

,
all with respect to the key variables. `C`

contains
all variables from both `A`

and `B`

,
including the key variables.

The row labels of `A`

and `B`

can
be key variables. Row labels are the row names of a table, or the
row times of a timetable.

performs
the outer-join operation with additional options specified by one
or more `C`

= outerjoin(`A,B`

,`Name,Value`

)`Name,Value`

pair arguments.

Row labels from the input tables `A`

and `B`

can
be keys, alone or in combination with other key variables. Row labels
are the row names of a table or the row times of a timetable. In general, `outerjoin`

copies
row labels from the input table `A`

to the output
table `C`

.

If

`A`

has no row labels, then`C`

has no row labels.If

`A`

has row labels, then`outerjoin`

copies row labels from`A`

to create row labels in`C`

.If you specify row labels from both

`A`

and`B`

as a key pair, then`outerjoin`

merges row labels from`B`

into row labels of`C`

where needed.If you specify row labels of

`A`

as a key, but do not specify row labels of`B`

as the matching key, then`outerjoin`

creates default row labels in`C`

where needed.If both

`A`

and`B`

are tables, but you do not specify either input table's row names as a key, then`outerjoin`

does not create row names in`C`

.

You cannot perform an outer join using the row labels of `A`

as
the left key and a variable of `B`

as the right key.
To perform the outer join, convert the row labels of `A`

to
a table variable and use the new table variable as a key.

Was this topic helpful?