首页 > 编程知识 正文

最小距离分类步骤,欧式距离怎么计算

时间:2023-05-04 18:28:35 阅读:173562 作者:3610

ajdyj距离分类器的Matlab实现ajdyj距离分类器是贝叶斯分类器的退化版本,在样本满足一定条件下成立。

代码是下一个:

function cls=mahalanobisclassifier [ vararg in ] [ x,m,sigma ]=parse inputs [ vararg in { : } ]; %分析输入的变量dis=Zeros(size(m,1 ),1 ); %ajdyj距离cls=Zeros(size(x,1 ); %每个样品所属的类别forI=1:size(x,1 ) )分类for j=1:size(m ) m,1 ) dis ) j )=) x ) I, )-m ) j,33: ) end function [x,m,sigma]=parseinputs(varargin ) %用于分析输入变量的函数narginchk(2) 2,inf ) validate attributes (x=ifnargin==2validate attributes (vararg in )、(numeric )、({'nonempty )、) nonsparse )、 (2d )、(ncols )、sigmm else if nargin==3validate attributes (vararg in )、((numeric )、)、{'nonempty )、(nonsparse )、…)、(ncols )。 {'numeric'}、{'nonempty '、' nonsparse '、 ' 2d '、' nrows '、size(varargin{2}、1 ) ncols )、size ) vargin Elsen=Length(varargin ); m=Zeros(n-2,size(x ) x,2 ); fork=2: n-1 validate attributes (vararg in (k )、(numeric )、({'nonempty )、) nonsparse )、) 2d、) nrows endvalidateattributes (vararg in (end )、(numeric )、({'nonempty )、) nonsparse )、 (2d )、(nrows )、size ) m 2 结束

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。