To calculate mahalanobis distance when the number of observations are less than the dimension
Show older comments
I am in the field of neuroscience and the data I am working on has the number of trials (or observations) less than the number of neurons (or dimensions). When I use mahal function on my data, I get the following error:
Error using mahal (line 38) The number of rows of X must exceed the number of columns.
Instead of posting my data, which is huge, you can run the following code that issues the same error.
A = rand(1,100); % new data
B = rand(10,100); % 10 observations and dimension 100
d = mahal(A,B);
Accepted Answer
More Answers (2)
Hugo Malagon
on 29 Aug 2017
0 votes
Reduce the dimensions. Principal component analyses, for example.
Ilya
on 30 Aug 2017
0 votes
For classification, use regularized discriminant or pseudo discriminant. Both options are supported in fitcdiscr. Regularization add a positive value to the diagonal of the covariance matrix to make it full-rank. Pseudo discriminant amounts to taking pinv.
Categories
Find more on Electrophysiology in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!