From: vortse a on 4 May 2010 06:07 The reduced speed is caused by the double loop and the if-else statement inside it. As it is, you do not take advantage of the vectorised capabilities of pdist. What I would do is: 1. calculate all distances regardless of class with a single instance of pdist. 2. reshape the output vector into NxN matrix form with squareform. 3. use bsxfun to create a N*N logical mask matrix of observation with different class id. 4. apply mask M to distance matrix D via indexing: D=D(M); 5. use find to obtain all relevant distances without the zeros in a vector form. Please exercise caution if it is possible to have a valid distance which is zero, then find will leave this observation out. If this is the case, then use find on the mask and use indexes from find to obtain your vector. If using pdist is still too slow for you, I guess there may be faster alteratives in the FEX, but you have to vectorise first.
|
Pages: 1 Prev: Reading Large Gzipped file Next: www.voguesneakers.com Cheap Jordans,Cheap Air Max,Cheap Nikes |