mdist.m

来自「动态模糊神经网络的例程」· M 代码 · 共 28 行

M
28
字号
function y=mdist(p,c,b)
% This program is used to compute Mahalanobis distance
% p--r*q matrix,which is the incoming sample data
% c--r*s matrix, which is the center matrix
% b--r*s matrix, which is the width matrix
% Revised 11-5-2006
% Copyright Wu Shiqian.
[r,q]=size(p);
[r,s]=size(c);
[r,s]=size(b);
y=zeros(s,q);
if r==1
   for i=1:s
      x=c(:,i)*ones(1,q);
      d=abs(p-x);
      xx=b(:,i)*ones(1,q);
      dd=d./xx;
      y(i,:)=dd.*dd;
   end
else
   for i=1:s
      x=c(:,i)*ones(1,q);
      d=abs(p-x);
      xx=b(:,i)*ones(1,q);
      dd=d./xx;
      y(i,:)=sum(dd.*dd);
   end
end

⌨️ 快捷键说明

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