📄 elec_cosines.m
字号:
function [Cos] = elec_cosines(A,B)
% ELEC_COSINES - Compute cosine of angle between electrode position vectors
%
% Useage: [Cos] = elec_cosines(A,B)
%
% A,B both Nx3 (X,Y,Z) electrode coordinates
% COS cosine angle between each row of A & B
% If A is Nx3 and B is Mx3, COS is NxM.
%
% Note: For a complete cosine matrix, let A = B.
%
% $Revision: 1.2 $ $Date: 2003/03/02 03:20:44 $
% Licence: GNU GPL, no implied or express warranties
% History: 08/01, Darren.Weber@flinders.edu.au
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if isempty(A), error('Input matrix A is empty\n'); end
if isempty(B), error('Input matrix B is empty\n'); end
As = size(A);
if ~isequal(As(2),3),
if isequal(As(1),3), A = A.';
else error('Input matrix A should be Nx3 [x y z] coordinates\n');
end
end
Bs = size(B);
if ~isequal(Bs(2),3),
if isequal(Bs(1),3), B = B.';
else error('Input matrix B should be Nx3 [x y z] coordinates\n');
end
end
for a = 1:size(A,1), Aa = A(a,:); A_len = sqrt( sum(Aa.^2));
for b = 1:size(B,1), Bb = B(b,:); B_len = sqrt( sum(Bb.^2));
if( Aa == Bb ), Cos(a,b) = 0;
else Cos(a,b) = dot(Aa,Bb) / (A_len * B_len);
end
end
end
return
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -