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

📄 euclidean.m

📁 Diversos ejemplos sobre la aplicacion de algoritmos geneticos.
💻 M
字号:
function dist = euclidean(x,y)
% function dist = euclidean(x,y)
% 
% Calculates the Euclidean distance between two vectors x and y
%                            A. Student, ICS 175A 
%  Inputs:
%    x, y:  2 vectors of real numbers, each of size 1 x n
%  Outputs:
%    dist: the Euclidean distance between x and y
[xr, xc] = size(x);
[yr, yc] = size(y);

if (xc ~= yc)
   error('input vectors must be the same length');
end

if (xr ~= 1  | yr ~= 1)
   error('inputs must both be row vectors (1 row, n columns)');
end

% calculate a vector of component_by_component distances
delta = x - y;

% now calculate the Euclidean distance
dist = norm(delta); %sqrt(delta.*delta);

⌨️ 快捷键说明

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