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

    %% Test for Category with No Corresponding Data  

%% 
% Create a categorical array, |A|. 
A = categorical({'plane' 'car' 'train' 'car' 'plane'},...
    {'boat' 'car' 'plane' 'train'}) 

%%
% |A| is a 1-by-5 categorical array.  

%% 
% Test to see if |boat| is a category in |A|. 
tf = iscategory(A,'boat') 

%%
% |iscategory| returns true, even though |A| does not contain any values
% from the category |boat|.