Error using pdist2 Too many input arguments

PS:遇到的问题

Error using pdist2

Too many input arguments.

 

Error inExhaustiveSearcher/knnsearch (line 207)

       [dist,idx] = pdist2(obj.X,Y, distMetric,arg{:}, 'smallest',numNN);

 

Error in ClassificationKNN/score(line 322)

            [CIDX,dist] = knnsearch(this.NS,X,'k',this.ModelParams.NumNeighbors,...

 

Error inClassificationKNN/predict (line 587)

                 posteriors = score(this,X);

 

Error in KNN_hog_new(line 16)

characterClass=predict(mdl,testHistograms(1,20:30));

解决:

help pdist2

 Calculates the distance between sets of vectors.

 

  LetX be an m-by-p matrix representing m points in p-dimensional space

  andY be an n-by-p matrix representing another set of points in the same

  space. This function computes the m-by-ndistance matrix D where D(i,j)

  isthe distance between X(i,:) and Y(j,:). This function has been

 optimized where possible, with most of the distance computations

 requiring few or no loops.

 

  Themetric can be one of the following:

 

 'euclidean' / 'sqeuclidean':

   Euclidean / SQUARED Euclidean distance. Note that 'sqeuclidean'

   is significantly faster.

 

 'chisq'

   The chi-squared distance between two vectors is defined as:

    d(x,y) = sum( (xi-yi)^2 / (xi+yi) ) / 2;

   The chi-squared distance is useful when comparing histograms.

 

 'cosine'

   Distance is defined as the cosine of the angle between two vectors.

 

 'emd'

   Earth Mover's Distance (EMD) between positive vectors (histograms).

   Note for 1D, with all histograms having equal weight, there is a simple

   closed form for the calculation of the EMD.  The EMD between histograms

    xand y is given by the sum(abs(cdf(x)-cdf(y))), where cdf is the

   cumulative distribution function (computed simply by cumsum).

 

 'L1'

   The L1 distance between two vectors is defined as:  sum(abs(x-y));

 

 

 USAGE

   D= pdist2( X, Y, [metric] )

 

 INPUTS

  X        - [m x p] matrix of mp-dimensional vectors

  Y        - [n x p] matrix of np-dimensional vectors

  metric   - ['sqeuclidean'],'chisq', 'cosine', 'emd', 'euclidean', 'L1'

 

 OUTPUTS

  D        - [m x n] distance matrix

 

 EXAMPLE

   %simple example where points cluster well

  [X,IDX] = demoGenData(100,0,5,4,10,2,0);

   D= pdist2( X, X, 'sqeuclidean' );

  distMatrixShow( D, IDX );

   %comparison to pdist

  n=500; d=200; r=100; X=rand(n,d);

  tic, for i=1:r, D1 = pdist( X, 'euclidean' ); end, toc

  tic, for i=1:r, D2 = pdist2( X, X, 'euclidean' ); end, toc

  D1=squareform(D1); del=D1-D2; sum(abs(del(:)))

 

  Seealso pdist, distMatrixShow

 

  Piotr's Image&Video Toolbox      Version 2.52

  Copyright 2012 Piotr Dollar.  [pdollar-at-caltech.edu]

  Please email me if you find bugs, or havesuggestions or questions!

  Licensed under the Simplified BSD License[see external/bsd.txt]

因为安装了Piotr'sImage&Video Toolbox这一工具箱,其里面也有同名函数,导致调用的是工具箱的函数,而不是matlab里头的函数。把这个toolboox的路径从path中删除就可以了。

所以一般发生too many input argument大部分原因都是因为自定义函数和系统函数重名。想要知道是不是这一错误,只要help 一下相关的文件名就可以了。

之前用低于10个变量的参数可以计算以为是matlab内置pdist2的函数问题。

### 回答1: 错误:#140:函数调用中参数过多。 这个错误通常是因为在函数调用时传递了太多参数。请检查函数的定义并确保传递的参数数量与函数定义中的参数数量相匹配。如果问题仍然存在,请检查函数调用的语法是否正确。 ### 回答2: "error" 是英文单词,意为“错误”。在计算机科学中,当程序发生异常情况或者运行出错时,都会提示“error”。错误可能是由于编码问题、网络连接问题、硬件故障等各种原因造成的。 在处理程序错误时,我们通常需要通过调试程序来找到导致错误的原因,以便修复程序的问题。在开发过程中,使用调试工具可以帮助程序员快速找到并修复错误。调试策略需要根据具体情况进行调整,以便更好地追踪错误信息和找到根本原因。 为了减少程序错误的发生,我们需要遵循一些最佳实践,如编写清晰易懂的代码、测试和验证程序等。良好的编码规范也可以避免代码错误的发生。我们还可以使用代码库、框架和工具等技术来加快开发流程,提高代码质量和可靠性。 总之,错误是程序开发中不可避免的问题,但我们可以通过使用适当的调试工具和编码实践来有效减少程序错误的发生。同时,我们也需要时刻保持开放和学习态度,以适应不断变化的技术和环境。 ### 回答3: Error 指的是错误或异常,它在计算机系统中经常出现。一般来说,它包括两个层次:语法错误和逻辑错误。 语法错误是指在编写程序时发生的拼写错误、标点符号等错误,这些错误会导致编译错误,程序无法执行。例如,缺少分号、括号不匹配、变量未定义等。 逻辑错误是指程序中的问题,使程序的输出不能如预期那样运行。这些类型的错误不会使程序崩溃,但会导致程序输出结果不正确。例如,程序运行时,某些条件未被考虑到,从而导致输出结果错误。 在计算机编程中,我们必须时刻关注错误。当程序中出现错误时,需要仔细检查代码以查明错误原因,并修正程序。要想确保编写的程序没有错误,就需要进行测试,以验证它的正确性。 总的来说,Error 在计算机系统中是一个常见的问题,但是我们可以通过检查代码和测试,确保程序的正确性,让程序能够顺利运行。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值