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

    %% Create and Label Ordinal Arrays

% Copyright 2015 The MathWorks, Inc.


%%
% Create an ordinal array from integer data, providing explicit labels.
quality = ordinal([1 2 3 3 2 1 2 1 3],...
   {'low' 'medium' 'high'})

%%
% Show that the first element is less than the second element (low is less
% than medium).
quality(1) < quality(2)

%%
% Create an ordinal array by binning values between 0 and 1 into thirds
% with labels |'small'|, |'medium'|, and |'large'|.
X = rand(5,2)
A = ordinal(X,{'small' 'medium' 'large'},[],[0 1/3 2/3 1])