B = mergecats(A, oldCategories)
B = mergecats(A, oldCategories, newCategory)
| Parameter | Description |
|---|---|
| A | Input categorical array. |
| oldCategories | Categories whose elements are merged. |
| newCategory | Name of the merged category. If omitted, the first category in oldCategories is kept. |
| Parameter | Description |
|---|---|
| B | Categorical array with merged category codes. |
mergecats replaces multiple categories by a single category and remaps all matching elements.
Categories not listed in oldCategories keep their values and relative order.
A = categorical({'red','blue','green'}); B = mergecats(A, {'blue','green'}, 'other'); categories(B)
| Version | Description |
|---|---|
| 2.0.0 | initial version |