% Learning toolbox. y = cos (2*pi*18* (1:399)/400); dtw (x,y);Table 2. 4 86. Clustergram documentation says that the default distance used is 'Euclidean' and the default linkage method is 'Average', same parameters I used. The Age values are in years, and the Weight values are in pounds. El código generado de pdist usa parfor (MATLAB Coder). pdist. D = pdist (Tree) returns D , a vector containing the patristic distances between every possible pair of leaf nodes of Tree, a phylogenetic tree object. For detailed information about each distance metric, see pdist. Trajectory should be represented as nx2 numpy array. However, notice what the root folder is - MATLAB Drive. out = pdist(X, 'euclidian') 0. how to find euclidean distance for an image MATLAB. The same piece of code seems to work just fine on later versions of the data, but going back in time (when observations should be less similar) the 'NaN's start appearing. The code is fully optimized by vectorization. 6 (7) 7. . . 'Pairwise distance between pairs of observations MATLAB pdist May 1st, 2018 - This MATLAB function returns the Euclidean distance between pairs of observations in X For code generation pdist uses parfor MATLAB ® Coder? treats the''Euclidean distance ED calculation in matlab MATLABPairwise distance between pairs of observations MATLAB pdist. function Distance = euclidean (x,y) % This function replaces the function pdist2 available only at the Machine. 1. distance=pdist(pair, 'euclidean'); "distance" will give you the euclidean distance between the first and second coordinates. 5°,仰角30°。当x轴. MATLAB compatibility module. sum (any (isnan (imputedData1),2)) ans = 0. Hooray!!! You have just reached the end of this article. Euclidean and Mahalanobis classifiers always return same. More precisely, the distance is given by. distfun must return an m2-by-1 vector of distances d2, whose kth element is the distance between XI. However, it's easier to look up the distance between any two points. 357 views (last 30 days) Show older comments. I think what you are looking for is what's referred to as "implicit expansion", a. All the points in the two clusters have large silhouette values (0. Forum; Pricing; Dash; MATLAB®. In Matlab I did run a Wilkoxon rank sum test to compare two variables. To explore classification models interactively, use the Classification Learner app. 转载自CSDN——再次写给我们这些浮躁的程序员; matlab - 3 自由度的机械臂distance of pairs of 3D points in matlab. These files will automatically appear in. pdist函数 D = pidst(X)主要计算X的行的距离,例如输入X为m n的矩阵,输出D为m (m-1)/2的向量 pdist 认为输入矩阵中,每一行是一个实例。MATLAB: we have data that give x y coordinates of occurences. e. Version History. Data can be combined with base map. I would like to sort these using the DTW algorithm. You need to have the licence for the statistics toolbox to run pdist. Your third party file c: oolboxclassifypdist2. 层次聚类是基于距离的聚类方法,MATLAB 中通过 pdist、linkage、 dendrogram、cluster 等函数 来完成。层次聚类的过程可以分这么几步: (1) 确定对象(实际上就是数据. Create a clustergram object for Group 18 in the MATLAB workspace. 7 249] these are (x, y, z) coordinates in mm, What is the easiest way to compute the distance (mm) between these two points in matlab, Thanks. It is widely used in science and engineering fields. Idx has the same number of rows as Y. Distance between all the dots in a scatterplot in R [closed]Q&A for people interested in statistics, machine learning, data analysis, data mining, and data visualizationCluster analysis is used in a variety of domains and applications to identify patterns and sequences: Clusters can represent the data instead of the raw signal in data compression methods. 一、pdist 和 pdist2 是MATLAB中用于计算距离矩阵的两个不同函数,它们的区别在于输入和输出以及一些计算选项。选项:与pdist相比,pdist2可以使用不同的距离度量方式,还可以提供其他选项来自定义距离计算的行为。输出:距离矩阵是一个矩阵,其中每个元素表示第一组点中的一个点与第二组点中的. The output, Y, is a. aN bN cN. (i,j) in. Allows to define a minimum size for each cluster, distance type (as supported by Matlab pdist) and the number of clusters which are allowed to have less than the minimum size. Pass Z to the squareform function to reproduce the output of the pdist function. The. Clusters indicate regions of images and lidar point clouds in segmentation algorithms. 文章浏览阅读1. Copy. 2. A distance function specified using @: D = pdist (X,@distfun) A distance function must be of form d2 = distfun (XI,XJ) taking as arguments a 1-by-n vector XI, corresponding to a single row of X, and an m2-by-n matrix XJ, corresponding to multiple rows of X. If we want to calculate the Minkowski distance in MATLAB, I think we can do the following (correct me if I'm wrong): dist=pdist ( [x (i);y (j)],'minkowski'); Up till here, the above command will do the equation shown in the link. sz = size (A); A1 = reshape (A, [1 sz]); A2 = permute (A1, [2 1 3]); D = sqrt (sum (bsxfun (@minus, A1, A2). ^2 ). The Mahalanobis distance is a measure between a sample point and a distribution. The default is 'kdtree' if K ≤ 10,. Para la generación de código, defina una función de punto de entrada que acepte las posiciones de los centroides de los grupos y el nuevo conjunto de datos, y devuelva el índice del grupo más cercano. 2954 1. It will do what you want, but is kind of overkill. Calculating euclidean distance MATLAB Answers Yesterday ur code did not work but now its working may be i have not used clear D i have extracted features. of matlab I do not have the pdist2 function. [D,I] = pdist2 ( ___) also returns the matrix I. However the result above just seems to be giving the row numbers of the two matrices. where(x>3)) (Not that there's anything wrong with where! The direct indexing may just be a more familiar form to. Link. Distance between all the dots in a scatterplot in R [closed]MATLABview函数详解MATLAB提供了设置视点的函数view。其调用格式为: view(az,el)az是azimuth(方位角)的缩写,EL是elevation(仰角)的缩写。它们均以度为单位。系统缺省的视点定义为方位角-37. Ideally, those points are in two or three dimensions, and the. If I have two points in 3d, A = [1579. Then execute 'memory' command in the Command Window and send the output. I need to build a for loop to calculate the pdist2 between the first row of A and all the rows of B, the second row of A and all. % Requires the Statistics and Machine Learning Toolbox because of the pdist() and squareform() functions. Get an overview of what functions in MATLAB® are, and learn how to use them. Documentation, examples, videos, and other support resources for MathWorks products including MATLAB and Simulink. I have a matrix A and I compute the dissimilarity matrix using the downloaded function. 1 How to use KNN in Matlab. % Call a mex file to compute distances for the standard distance measures % and full real double or single data. Define an entry-point function named findNearestCentroid that accepts centroid positions and new data, and then find the nearest cluster by using pdist2. As you have mentioned that you are trying to solve NP-complete problem and need all the permutations, I suggest you write a small script which generates all the permutations by rearranging the elements in the array itself. 8717. Euclidean and Mahalanobis classifiers always return same. This is my forst class using the app and I am at beginner level, so please bear with me ;) (Also, english. For example, if we do. I have a naive so. List in Mathematica® [6], pdist and clustergra m in MATLAB ® [7, 8], and single spreadsheet rows in SPSS [9]. As stated in the error, knnimpute uses pdist, the pairwise distance. M is the number of leaves. All the points in the two clusters have large silhouette values (0. You could compute the moments of each. View More. Supervised and semi-supervised learning algorithms for binary and multiclass problems. d(u, v) = max i | ui − vi |. as arguments a 1-by-n vector XI, corresponding to a single row of X, and an m2-by-n matrix XJ, corresponding to multiple rows of X. pdist is probably much more than you actually need, assuming that by "distance" you mean a simple subtraction. The output from pdist is a symmetric dissimilarity matrix, stored as a vector containing only the (23*22/2) elements in its upper triangle. If the NaNs don't occur in the same locations, you will have to first find the valid indices by something like, `X (~isnan (X)| isnan (Y))'. . MATLAB pdist A distance metric is a function that defines a distance between two observations. I have tried R (dist function), Matlab (pdist function), and cloud computing (to increase RAM). If the sizes of A and B are compatible, then the two arrays implicitly expand to match each other. d = ( y − μ) ∑ − 1 ( y − μ). What are you really trying to do? Like find the two points farthest from each other? The pdist command requires the Statistics and Machine Learning toolbox. 1. calculate_distance. to_mlab_linkage# scipy. I want to implement some data mining algorithms in Matlab and after the analyze the data. Where p = 1 (for now), n is as large as the number of points and d as large as the number of dimensions (3 in this case). The syntax for pdist looks like this:Theme. Sign in to answer this question. Hi, please I want to calculate the distance. See answers from experts and users with examples, alternatives and tips for MATLAB and Python. Then use pdist to transform the 10-dimensional data into dissimilarities. Specify a cell array if the distance metric requires extra arguments. Let X be an MxP matrix representing m points in P-dimensional space and Y be an NxP matrix representing another set of points in the same space. In later versions of MATLAB, this is not an “Undefined function or variable” error, and MATLAB. I'm doing this because i want to know which point has the smallest average distance to all the other points (the medoid). Z (2,3) ans = 0. e. sqrt(((u-v)**2). pdist supports various distance metrics: Euclidean. pdist (X): Euclidean distance between pairs of observations in X. Tomas on 5 Feb 2014. [D,I] = pdist2 ( ___) also returns the matrix I. C = A. As far as I know, there is no equivalent in the R standard packages. Find the treasures in MATLAB Central and. Y = pdist(X,'euclidean') Create an agglomerative hierarchical cluster tree from Y by using linkage with the 'single' method for computing the shortest distance between clusters. Pdist in Matlab blows up instantly of course ;) Is there a way to cluster subsets of the large data first, and then maybe do some merging of similar clusters? I don't know if this helps any, but the data are fixed length binary strings, so I'm calculating their distances using Hamming distance (Distance=string1 XOR string2). 🄳. 0000 3. To get the distance, you may use the MATLAB function pdist: D = pdist(X) This computes the Euclidean distance between pairs of objects in m-by-n data matrix X. e loop through the "loc_i" variable) to find the distance between a particular coordinate and the rest of the coordinates. You need to rename or delete c: oolboxclassifypdist2. first of all, sorry I did not see your comment. Sign in to comment. 转载自CSDN——再次写给我们这些浮躁的程序员; matlab - 3 自由度的机械臂Documentation, examples, videos, and other support resources for MathWorks products including MATLAB and Simulink. pdist. You use the sdo. pdist-> linkage-> dendrogram I found they are different, but cannot find an explanation for that difference. Z = linkage(Y,'single') If 0 < c < 2, use cluster to define clusters from. Your third party file c: oolboxclassifypdist2. 8322 268. I would like to make a loop that computes a distance between all matrix arrays, and save them in a distance matrix. 2711 122. Upgrade is not an option. Run the command. m. I have tried R (dist function), Matlab (pdist function), and cloud computing (to increase RAM). You can see matlab pdist method to find a list of easy-to-used distance calculating method. I am using a classifier via libsvm, with a gaussian kernel, as you may have noticed from the variable names and semantics. m at master · nmrshll/matlab-pca-examplesscipy. Description. There are 100 data points in the original data set, X. Learn more about distance bigdata MATLAB So I have a matrix that is 330,000 observations = rows x 160 variables = columns. k = 2 B_kidx = knnsearch(B, A, 'K', k) then B_kidx will be the first two columns of B_idx, i. C = A. pdist. ) The -r switch is also supported for Windows Enhanced Metafiles but is not supported for Ghostscript. Hi everyone. I need help with standard euclidean distance, knew would someone help with matlab code ? I can not use, matlab function, pdist, pdist2. Converts a linkage matrix Z generated by the linkage function of this module to a MATLAB(TM) compatible one. The Canberra distance between two points u and v is. SciPy(scipy. % I take the first element of A, but I assume it is a new one new_element = A (1,:);Matlab is a platform for technical computing. 1w次,点赞12次,收藏54次。pdist成对观测值之间的两两距离语法D = pdist(X)D = pdist(X,Distance)D = pdist(X,Distance,DistParameter)说明D= pdist(X)返回X中成对观测值之间的欧几里德距离。D= pdist(X,Distance)使用Distance指定的方法返回距离。D= pdist(X,Distance,DistParameter)使用Distance和DistParameter指定. Implement Matlab functions for comparing two vectors in terms of: a. I have a set of points from a complex function that I am trying to produce a 3D shape of, and have had no luck so far. e. If the sizes of A and B are compatible, then the two arrays implicitly expand to match each other. When doing baysian optimization we often want to reserve some of the early part of the optimization to pure exploration. 4. In thisPairwise distances between observations, specified as a numeric row vector that is the output of pdist, numeric square matrix that is the output of pdist2, logical row vector, or logical square matrix. At the moment i am using the pdist function in Matlab, to calculate the euclidian distances between various points in a three dimensional cartesian system. This is the form that pdist returns. Link. k = 2 B_kidx = knnsearch(B, A, 'K', k) then B_kidx will be the first two columns of B_idx, i. 9448. The score in similarities (i,j) represents the similarity between the i th document encoded by bag and queries (j). function Distance = euclidean (x,y) % This function replaces the function pdist2 available only at the Machine. Improve this answer. Syntax. , Natick, MA). Both functions use the same syntax except that the createns function has the 'NSMethod' name-value pair argument, which you use to choose the nearest neighbor search method. Right-click Group 18, then select Export Group to Workspace. T = cluster (Z, 'maxclust' ,3); Create a dendrogram plot of Z. La función pdist puede usar CacheSize=cache solo cuando el argumento Distance es 'fasteuclidean', 'fastsquaredeuclidean' o 'fastseuclidean'. I am getting the following error: Theme. Classification. Note that generating C/C++ code requires MATLAB® Coder™. matlab; large-data; distance-functions; euclidean; unicoder. pdist. Rather it seems that the correct answer for these places should be a '0' (as in, they do not have anything in common - calculating a similarity measure using 1-pdist) . You can define your own distance function to handle complex-valued data. Distance is calculated using two distance funstions: Haversine and Pythagoran. pdist returns a condensed distance matrix. I have a vector X which contain x and y value in column 1 and 2 respectively. The matrix I contains the indices of the observations in X corresponding to the distances in D. Parallel pools can be leveraged in MATLAB and Simulink by. example. distance=pdist(pair, 'euclidean'); "distance" will give you the euclidean distance between the first and second coordinates. If the correlation² between two random variables is r, then their correlation distance is defined as d=1-r. If I have two points in 3d, A = [1579. CanberraSimilarity. I have tried R (dist function), Matlab (pdist function), and cloud computing (to increase RAM). matlab; large-data; distance-functions; euclidean; unicoder. The matrix I contains the indices of the observations in X corresponding to the distances in D. Any ideas how I can input a vector of points like this? squareform returns a symmetric matrix where Z (i,j) corresponds to the pairwise distance between observations i and j. Copy. Matlab princomp function running under Matlab R2007b with the Statistics Toolbox (The Mathworks, Inc. help with matlab code I can not use matlab function pdist pdist2 I need standard euclidean distance between two vectors Distance ? Hamming Vs Euclidean Distance of a coding scheme is the lowest Fourier transform gray code M QAM Matlab Code Matlab Codes matrix algebra. As for the PDist itself, it does appear to have some construct support for. D = pdist2 (X,Y) returns a matrix D containing the Euclidean distances. The patristic distances are computed by following paths through the branches of the tree and adding the patristic branch distances originally created with the seqlinkage function. m or remove that directory from your MATLAB path. 1 answer. Find the treasures in MATLAB Central and discover how the community can help you! Start Hunting! Discover Live Editor. Categories MATLAB Language Fundamentals Matrices and Arrays Shifting and Sorting Matrices. Development install. Clustering Part 2 K means clustering inHow to use it. end. More precisely, the distance is given. For example, you can find the distance between observations 2 and 3. *B multiplies arrays A and B by multiplying corresponding elements. For a recent project I needed to calculate the pairwise distances of a set of observations to a set of cluster centers. spatial. squareform (distvec) returns the 5x5 distance matrix. . Description. D = pdist (Tree) returns D , a vector containing the patristic distances between every possible pair of leaf nodes of Tree, a phylogenetic tree object. % test pdist2 vs. Python:generator的send()方法流程分析; 多边形面积_ssl1213_计算几何; html5中的points,Can I plot HTML5 Canvas x/y points. 列?. Learn how to use the pdist command to calculate the distance between points in a matrix and store the results in a matrix with the row form. it must have the same name throughout the function. e. I need to create a function that calculates the euclidean distance between two points A (x1,y1) and B (x2,y2) as d = sqrt ( (x2-x1)^2+ (y2-y1)^2)). - "Compute spearman correlation coefficient with Matlab/CUDA"matlab pdist,pdist用法; STM32F103五分钟入门系列(一)跑马灯(库函数+寄存器. MY-by-N data matrix Y. 0414 3. Documentation, examples, videos, and other support resources for MathWorks products including MATLAB and Simulink. Learn more about for loop, matrix, matlab, pdist MATLAB Hi everybody, i have two 3D matrix A and B with different lengths. Really appreciate if somebody can help me. y = squareform(Z) y = 1×3 0. matrix = rand (132,18) Distance will be a vector [1x8646]; D_matrix = squareform (Distance,'tomatrix'); is a matrix 132x132 contaning all the pairwise distances between te. c = cophenet(Z,Y) Description. However, it may take a long time when the data matrix is large. First, create the distance matrix and pass it to cmdscale. For a dataset made up of m objects, there are pairs. Answered: Muhammd on 14 Mar 2023. % Autor: Ana C. % n = norm (v) returns the Euclidean norm of vector v. Rows of X and Y correspond to observations, That is, it works on the ROWS of the matrices. similarities = cosineSimilarity (bag,queries) returns similarities between the documents encoded by the bag-of-words or bag-of-n-grams model bag and queries using tf-idf matrices derived from the word counts in bag. distance of pairs of 3D points in matlab Is it possible to write a code in matlab without loop arrays matlab matrix euclidean distance. All elements of the condensed distance matrix must be finite, i. matlab code for the mahalanobis distance function helped me in my Pattern recognition''Pairwise distance between pairs of observations MATLAB pdist May 1st, 2018 - This MATLAB function returns the Euclidean distance between pairs of observations in X For code generation pdist uses parfor MATLAB ® Coder? treatsA Nearest neighbor search locates the k -nearest neighbors or all neighbors within a specified distance to query data points, based on the specified distance metric. 8 or greater), indicating that the clusters are well separated. [MATLAB-zscore] of time series 26, followed by correlation coe cients normalization to z scores using the Fisher. Pairwise distance between observations. Genetic clustering and sequence analysis are used in bioinformatics. The matrix I contains the indices of the observations in X corresponding to the distances in D. 1 Matlab pdist2 : Out of memory. Sign in to answer this question. MATLAB Function Reference : pdist3. cartography distance euclidian geography map MATLAB pdist. The distances are returned in a one-dimensional array with length 5*(5-1)/2 = 10. The Mahalanobis distance from a vector y to a distribution with mean μ and covariance Σ is. 126; asked Feb 19, 2018 at 10:51. This can achieved with the following code: % Define the coordinate points of the nodes. com account, please see github. MATLAB Calculate L2 Euclidean distance kawahara ca. To save your figure as a graphics-format file, specify a format switch and filename. How to calculate pairwise distance in MATLAB pdist? Therefore, D1 (1) and D1 (2), the pairwise distances (2,1) and (3,1), are NaN values. 否则,pdist 使用标准算法来计算欧几里德距离。 如果距离参数为 'fasteuclidean'、'fastsquaredeuclidean' 或 'fastseuclidean',并且 cache 值太大或为 "maximal",则 pdist 可能会尝试分配超出可用内存容量的格拉姆矩阵。在这种情况下,MATLAB ® 会引发错误。 示例: "maximal"I'm writing a function in which I call the built in Matlab function 'pdist'. Y = pdist (X, 'canberra') Computes the Canberra distance between the points. Syntax. Any help. {"payload":{"allShortcutsEnabled":false,"fileTree":{"":{"items":[{"name":"+local","path":"+local","contentType":"directory"},{"name":"+lp","path":"+lp","contentType. 2. D = seqpdist (Seqs) returns D , a vector containing biological distances between each pair of sequences stored in the M sequences of Seqs , a cell array of sequences, a vector of structures, or a matrix or sequences. y = squareform (Z) squareform returns a symmetric matrix where Z (i,j) corresponds to the pairwise distance between observations i and j. 1. Am I correct?This MATLAB function returns the Euclidean distance between pairs of observations in X. Pairwise distance between pairs of observations MATLAB pdist. Detailed examples of Dendrograms including changing color, size, log axes, and more in MATLAB. Use the 5-nearest neighbor search to get the nearest column. 9448. However, my matrix is so large that its 60000 by 300 and matlab runs out of memory. In my previous runnings of the same code it was. 0 matlab use my own distance function for pdist. 9448. pd = makedist (distname) creates a probability distribution object for the distribution distname , using the default parameter values. distance m File Exchange MATLAB Central MathWorks. Jarak euclidean distance matlab Pemrograman Matlab. The code is fully optimized by vectorization. Thanks for your help. dist=pdist ( [x (i);y (j)],'minkowski'); Up till here, the above command will do the equation shown in the link. sparse)を使うと疎行列(スパース行列)を効率的に扱うことができる。. ^2,3)); This calculates the distance between any two points explicitly (thus, does twice as much work, and takes over twice as much space: 6400 instead of 3180 elements). I'm not sure whether that's pairwise for every one of your 262322*4 (=1049288) elements, but if so then a matrix of doubles 1049228^2 in size is hundreds of GB, clearly not going to fit in RAM. I need standard euclidean distance between two vectors. matlab use my own distance function for pdist. Learn more about distance, euclidean, pdist, coordinates, optimisation MATLAB Hi all, Many of the codes I am currently using depend on a simple calculation: the distance between a single point and a set of other points. The most efficient pairwise distance computation. I need to build a for loop to calculate the pdist2 between the first row of A and all the rows of B, the second row of A and all. 8 语法 math. – am304. . You can create your graph using the "digraph" function, and determine the weights using the "pdist" function. ) Y = pdist(X,'minkowski',p) Description . The tutorial purpose is to teach you how to use the Matlab built-in functions to calculate the statistics for different data sets in different applications; the tutorial is intended for users running a professional version of MATLAB 6. Upgrade is not an option. Rows of X and Y correspond to observations, That is, it works on the ROWS of the matrices. spatial. 2 279] B = [1674. MATLAB pdist function. % Autor: Ana C. Euclidean Distance Back to the Math complete. . Y = pdist(X) Y = pdist(X,'metric') Y = pdist(X,distfun,p1,p2,. y = squareform (Z) squareform returns a symmetric matrix where Z (i,j) corresponds to the pairwise distance between observations i and j. obtainedusingFSL[FSL-fslmeants]22–24weredetrendedanddemeaned[MATLAB-detrend],andtherfMRI datawasbandpassltered[MATLAB-lt˛lt]intherangeof0. as Walter said, it is better, to rewrite the algorithm to not need as much memory. D can also be a more general dissimilarity vector or matrix that conforms to the output format of pdist or pdist2, respectively. *B multiplies arrays A and B by multiplying corresponding elements. The createns function also creates an ExhaustiveSearcher object. . git push) and not just use 'irfu-matlab'. loop on matrix array. Sorted by: 1. Feb 25, 2018 at 9:36. For example, you can find the distance between observations 2 and 3. Make sure the names inside the functions are internally consistent. Find Nearest Points Using Custom Distance Function. There is no in-built MATLAB function to find the angle between two vectors. Find more on Random Number Generation in Help Center and File Exchange. I used Python to find the points in a . Am lost please help. someone help with matlab code I can not use matlab function pdist pdist2 I need standard euclidean distance between two vectors. Add a comment |tutorial, we assume that you know the basics of Matlab (covered in Tutorial 1) and the basics of statistics. It computes the distances between. The tutorial purpose is to teach you how to use the Matlab built-in functions to calculate the statistics for different data sets in different applications; the tutorial is intended for users running a professional version of MATLAB 6. y = squareform (Z) Compute the Euclidean distance. Pass Z to the squareform function to reproduce the output of the pdist function. pdist supports various distance. I know about the prctile function, but it requires the Statistics Toolbox in Matlab which I do not have. Commented: Walter Roberson on 6 Feb 2014. It is recommended you first add SSH keys to your github. which -all pdist will list all the pdist MATLAB files in your MATLAB path. Reply More posts you may like. cmdscale takes as an input a matrix of inter-point distances and creates a configuration of points. ParameterSpace to specify the probability distributions for model parameters that define a parameter space for sensitivity analysis. The same piece of code seems to work just fine on later versions of the data, but going back in time (when observations should be less similar) the 'NaN's start appearing. Y = pdist(X) Y = pdist(X,'metric') Y = pdist(X,distfun,p1,p2,. The first output is based on Haversine function, which is more accurate especially for longer distances. I have tried using the following to do this: Theme. The matrix with the coordinates is formatted as: points [ p x n x d ]. 例子. You can specify D as either a full n-by-n matrix, or in upper triangle form such as is output by pdist.