MATLAB中classify函数的使用

具体的原理不懂,但是希望通过这个例子告诉自己怎么用这个函数

%training为训练数组

MATLAB中classify函数的使用_第1张图片

training=[0.056  0.084  0.031  0.038  0.0081  0.022;
               0.040  0.055  0.100  0.110  0.0220  0.0073;
  0.050  0.074  0.041  0.048  0.0071  0.020;
  0.045  0.050  0.110  0.100  0.0250  0.0063;
  0.038  0.130  0.079  0.170  0.0580  0.043;
  0.030  0.110  0.070  0.160  0.0500  0.046;
  0.034  0.095  0.058  0.160  0.200  0.029;
  0.030  0.090  0.068  0.180  0.220  0.039;
  0.084  0.066  0.029  0.320  0.012  0.041;
  0.085  0.076  0.019  0.300  0.010  0.040;
  0.064  0.072  0.020  0.250  0.028  0.038;
  0.054  0.065  0.022  0.280  0.021  0.040;
  0.048  0.089  0.062  0.260  0.038  0.036;
  0.045  0.092  0.072  0.200  0.035  0.032;
  0.069  0.087  0.027  0.050  0.089  0.021];

%group为已知的分类数组
group=[1;1 ;1 ;1 ;2 ;2 ;1; 1; 2 ;2 ;2 ;2 ;2 ;2 ;1];

%sample为待分类的数据
sample=[0.052  0.084  0.021  0.037  0.0071  0.022;
               0.041  0.055  0.110  0.110  0.0210  0.0073;
               0.030  0.112  0.072  0.160  0.056  0.021;
               0.074  0.083  0.105  0.190  0.020  1.000];
[class,err]=classify(sample,training,group,'mahalanobis')


输出结果为:

class =

 

       1 

       1

       2

       2


你可能感兴趣的:(MATLAB中classify函数的使用)