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

📄 point_to_space_distance.m

📁 一个用EM算法的源程序
💻 M
字号:
function pointToSpaceDistance = point_to_space_distance(samples, subspaceBasis)
% function pointToSpaceDistance = point_to_space_distance(samples, subspaceBasis)
%
% Computes the Euclidean distance between one or more vectors and a subspace. 
%  (i.e. the normal of (the vectors minus their projection onto the subspace ))
% 
% Inputs:
%   samples -       The samples to be projected, represented as columns.
%
%   subspaceBasis - The basis for the subspace to project onto; each column
%                   is a basis vector.
%
% Output:
%   pointToSpaceDistance -  A row vector of distances between the points and
%                           the subspace.

if (size(samples,2) == 1),
    pointToSpaceDistance = norm(samples - subspaceBasis*(subspaceBasis'*samples));
else
    perpVectors = samples - subspaceBasis*(subspaceBasis'*samples);
    pointToSpaceDistance = sqrt(sum(perpVectors.*perpVectors));
end

⌨️ 快捷键说明

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