categorical.isprotected
categorical: TF = isprotected (C)
Test if categorical array is protected.
TF = isprotected (C) returns a logical scalar
TF, which is true, if the categorical array C is
protected, and false otherwise.
Source Code: categorical
isprotected reports whether the category list is locked. A nominal array is unprotected: assigning a new label simply extends its categories ...
N = categorical ({'M'; 'S'})
N =
2x1 categorical array
M
S
isprotected (N)
ans = 0
... whereas ordinal arrays (and ones built with 'Protected', true) are protected, so only their declared categories may be used.
O = categorical ({'M'; 'S'}, {'S', 'M', 'L'}, 'Ordinal', true)
O =
2x1 categorical array
M
S
isprotected (O)
ans = 1