how to create mahalanobis function in matlab?

6 ビュー (過去 30 日間)
Brity Jain
Brity Jain 2018 年 10 月 2 日
回答済み: VM Sreeram 2023 年 7 月 5 日
I want to create mahalanobis function in matlab not by using direct 'mahal' function.

回答 (1 件)

VM Sreeram
VM Sreeram 2023 年 7 月 5 日
Here’s an example implementation of mahalanobis function:
function d = mahalanobis(x, y, C)
d = sqrt((x-y) * inv(C) * (x-y)');
end
Here, x and y are the two vectors between which you want to calculate the Mahalanobis distance, and C is the covariance matrix. You can use this function to calculate the Mahalanobis distance between x and y by passing these arguments to the function.

カテゴリ

Help Center および File ExchangeGraph and Network Algorithms についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by