Anyone? Any Vectorization wizard? Thank You.

# Computing Mahalanobis Distance Between Set of Points and Set of Reference Points

9 views (last 30 days)

Show older comments

Hello,

I have an n x p matrix - mX which is composed of n points in R^p.

I have another m x p matrix - mY which is composed of m reference points in R^p.

I would like to create an n x m matrix - mD which is the Mahalanobis Distance matrix.

Namely, is computes the following:

mD(i, j) = (mX(j, :) - mY(i, :)) * inv(mC) * (mX(j, :) - mY(i, :)).';

Where mC is the given Mahalanobis Distance PSD Matrix.

It is easy to be done in a loop, is there a way to vectorize it?

Namely, is the a function which its inputs are mX, mY and mC and its output is mD and fully vectorized without using any MATLAB toolbox?

Thank You.

### Accepted Answer

### More Answers (1)

Image Analyst
on 9 Aug 2015

##### 2 Comments

Image Analyst
on 9 Aug 2015

### See Also

### Categories

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!