M = mahal(obj,X)
M = mahal(obj,X,Name,Value)
Numeric matrix of size n-by-p, where p is the number of predictors in obj, and n is any positive integer. mahal computes the Mahalanobis distances from the rows of X to each of the K means of the classes in obj.
Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.
Size and meaning of output M depends on whether the ClassLabels name-value pair is present:
The Mahalanobis distance d(x,y) between n-dimensional points x and y, with respect to a given n-by-n covariance matrix S, is
Find the Mahalanobis distances from the mean of the Fisher iris data to the class means, using distinct covariance matrices for each class:
load fisheriris obj = fitcdiscr(meas,species,... 'DiscrimType','quadratic'); mahadist = mahal(obj,mean(meas)) mahadist = 220.0667 5.0254 30.5804