⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mindisclassifier.m

📁 PCA、LDA人脸检测
💻 M
字号:
function k=MinDisClassifier(n,m,classcenter,x)
% MINDISCLASSIFIER is the implementation of minimum-distance classifier
% n denotes the dimension of the problem
% m is the number of classes
% classcenter is a matrix(n*m),classcenter(i,j) represents the i-th 
% component of the j-th class
% x is a incoming pattern
% 
% the function will return the number k into which x is classified 

if nargout>1
    error('Too many output arguments.');
end
if nargin~=4
    error('Wrong number of input arguments.');
end
[cn,cm]=size(classcenter);
if cm~=m | cn~=n
    error('Wrong input data.');
end

k=1;
max=dot(x,classcenter(:,1))-0.5*dot(classcenter(:,1),classcenter(:,1));

for j=2:m
    if (dot(x,classcenter(:,j))-0.5*dot(classcenter(:,j),classcenter(:,j)))>max
        max=dot(x,classcenter(:,j))-0.5*dot(classcenter(:,j),classcenter(:,j));
        k=j;
    end
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -