필터 지우기
필터 지우기

Issue regarding mahalanobis distance function

조회 수: 2 (최근 30일)
Marc Saade
Marc Saade 2019년 2월 17일
댓글: Geoff Hayes 2019년 2월 17일
Hi, i am currently working on my thesis and i am trying the mahalanobis distance function to get the answer. The problem is i have a matrix of 242 lines and 2 colums and. In the first columns i have different mean values and in second column i have the standard deviation. What i want is at each line(in a for loop) i want to compare the line standard deviation and mean with the first line. Ultimately having a vector of 1 column and 242 lines. Can someone tell me how this can be done.
I tried using the 'mahal(X,Y)' but it does not work when dimension of both vectors are the same.

답변 (2개)

Geoff Hayes
Geoff Hayes 2019년 2월 17일
Marc - please clarify what you mean by i want to compare the line standard deviation and mean with the first line. If X is your 242x2 matrix, then isn't the comparison just
mDist = mahal(X(1,:), X(k, :));
where k is the kth row that you are comparing to the first row in the for loop?
  댓글 수: 2
Marc Saade
Marc Saade 2019년 2월 17일
yes i tried that but it did not work. it give this error:
Error using mahal (line 38)
The number of rows of X must exceed the number of columns.
Error in Untitled2 (line 37)
mDist(k) = mahal(s(1,:), s(k, :));
Geoff Hayes
Geoff Hayes 2019년 2월 17일
Marc - from mahal it seems that the second input needs more rows than columns. Are you sure that you want to be using mahal?

댓글을 달려면 로그인하십시오.


Marc Saade
Marc Saade 2019년 2월 17일
what is theire other that function, is theire a function that calculates the cos distance?
  댓글 수: 1
Geoff Hayes
Geoff Hayes 2019년 2월 17일
are you just trying to find the nearest distance between the two sets of values? perhaps just use the squared distance? Something like
dist = sqrt(sum((X(1,:) - X(k, :))^2));
Or would this not produce the results you need/expect?

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by