| Statistics Toolbox | Search  Help Desk |
| classify | Examples See Also |
Syntax
class = classify(sample,training,group)
Description
class = classify(sample,training,group) assigns each row of the data in sample into one of the groups that the training set, training, is already divided into. sample and training must have the same number of columns.
The vector group contains integers, from one to the number of groups, that identify which group each row of the training set belongs. group and training must have the same number of rows.
The function returns class, a vector with the same number of rows as sample. Each element of class identifies the group to which the corresponding element of sample has been assigned. The classify function determines into which group each row in sample belongs by computing the Mahalanobis distance of each row in sample to each row in training.
Example
load discrim
sample = ratings(idx,:);
training = ratings(1:200,:);
g = group(1:200);
class = classify(sample,training,g);
first5 = class(1:5)
first5 =
2
2
2
2
2
See Also
mahal