mergecats
Merge categories in a categorical array.
📝Syntax
B = mergecats(A, oldCategories)
B = mergecats(A, oldCategories, newCategory)
📥Input Arguments
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.
📤Output Arguments
Parameter Description
B Categorical array with merged category codes.
📄Description

mergecats replaces multiple categories by a single category and remaps all matching elements.

Categories not listed in oldCategories keep their values and relative order.

💡Examples
Merge several categories into one category.
A = categorical({'red','blue','green'}); B = mergecats(A, {'blue','green'}, 'other'); categories(B)
🔗See Also
addcatsremovecatsrenamecatssetcats
🕔Version History
Version Description
2.0.0 initial version
Edit this page on GitHub