www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/ConvertMissingStringsToUndefinedCategoricalValuesExample.m

    %% Convert Missing Strings to Undefined Categorical Values
% Convert a string array with missing elements to a categorical array. Where 
% the string array contains a missing value, the categorical array contains
% an undefined value.
str = string({'jet','plane','helicopter'});
str(5) = 'plane';
str

%%
C = categorical(str)