www.pudn.com > LBG_GA.rar > disteu.m, change:2011-03-14,size:505b


function d = disteu(x, y)
% x=rand(12,30);
% y=rand(12,20);
[N,M] = size(x);
[P,M2] = size(y); 

if (N ~= P)                                         %如果M与M2不相等,提示出错
    error('Matrix dimensions do not match.')
end

d = zeros(M,M2);

if (M< M2)
    copies = zeros(1,M2);
    for n = 1:M
        d(n,:) = sum((x(:,n+copies) - y) .^2, 1);
    end
else
    copies = zeros(1,M);
    for p = 1:M2
        d(:,p) = sum((x - y(:,p+copies)) .^2, 1)';
    end
end

d = d.^0.5;
% d_sum=sum(sum(d));
end