Home > FR3DSource > zDistance.m

# zDistance

## PURPOSE zDistance(A,B) finds the Euclidean distances between the rows of A and of B

## SYNOPSIS function [D] = zDistance(A,B)

## DESCRIPTION ` zDistance(A,B) finds the Euclidean distances between the rows of A and of B`

## CROSS-REFERENCE INFORMATION This function calls:
This function is called by:
• xScatterPairs xScatterPairs displays multiple 3d scatter plots of pair parameters, with a menu that allows one to color points in different orders, or display different nucleotides from the candidates
• zAnalyzePair zAnalyzePair(N1,N2,CL) computes distances, angles, and classification
• zCheckHydrogen This program is generated by zGenerateCheckHydrogen.m
• zMutualDistance zMutalDistance(A,L) finds the mutual distances between the rows of A and
• zPhosphateInteractions zPhosphateInteractions checks all nearby pairs of bases for base-phosphate

## SOURCE CODE ```0001 % zDistance(A,B) finds the Euclidean distances between the rows of A and of B
0002
0003 function [D] = zDistance(A,B)
0004
0005 [M,t] = size(A);
0006
0007 if nargin < 2,
0008
0009   G = A * A';                        % inner products of rows of A
0010
0011   a = diag(G);                       % sums of squares of each row of A
0012
0013   X = repmat(a,1,M);                 % repeat a in each row
0014
0015   D = sqrt(X + X' - 2*G);            % |u-v| = |u|^2 + |v|^2 - 2 u . v
0016
0017 else
0018
0019   a = sum((A.*A)');                  % sum of squares of each row of A
0020   b = sum((B.*B)');                  % sum of squares of each row of B
0021
0022   M = length(a);                     % number of rows in A
0023   N = length(b);                     % number of rows in B
0024
0025   X = repmat(b,M,1);                 % repeat a in each row
0026   Y = repmat(a',1,N);                % repeat b in each column
0027
0028   G = A * B';                        % inner products of rows of A
0029
0030   D = sqrt(X + Y - 2*G);             % |u-v| = |u|^2 + |v|^2 - 2 u . v
0031
0032 end```

Generated on Fri 03-Apr-2009 09:52:35 by m2html © 2003