大家好,我用matlab运算空间距离时遇到以下问题,请各位高手指教啊:
程序如下:
function D = distance(xc,yc)
% PURPOSE: Computes the list of pairwise distances for a given set of locations (loc).
% ----------------------------------------------------------
% Usage: D = distance(xc,yc)
% where: xc,yc are vectors of latt-long coordinates for each location
% ----------------------------------------------------------
% Returns: D = (n x n)-matrix of pairwise distances
% Written by: TONY E. SMITH, 2/10/98
n = length(xc) ; %number of locations
% Start procedure.
X = xc ; %column vector
Y = yc ; %column vector
U = ones(n,1) ; %column vector
XX = X*U' - U*X' ;
YY = Y*U' - U*Y' ;
D = (XX.^2 + YY.^2) ;
在标红的那地方一直出现错误,提示为:??? Input argument "xc" is undefined.
Error in ==> distance at 11
n = length(xc) ; %number of locations
请各位给小弟解释一下,万分感激!