setcats
Set the category list of a categorical array.
📝Syntax
B = setcats(A, newCategories)
📥Input Arguments
Parameter Description
A Input categorical array.
newCategories Complete replacement category list.
📤Output Arguments
Parameter Description
B Categorical array using exactly the categories listed in newCategories.
📄Description

setcats replaces the category list of a categorical array.

Elements whose previous category is not present in newCategories become undefined. Categories in newCategories that were not previously present are added as unused categories.

💡Examples
Keep only selected categories.
A = categorical({'red','blue','green'}); B = setcats(A, {'red','blue'}); isundefined(B)
Add an unused category through a complete category list.
A = categorical({'red','blue'}); B = setcats(A, {'red','blue','green'}); categories(B)
🔗See Also
addcatsremovecatsisundefinedcategories
🕔Version History
Version Description
2.0.0 initial version
Edit this page on GitHub