euclidean distance,output

we compute the euclidean distance for each received word as follows:
  • 010 ---> 0.154
  • 011 ---> 0.256
  • 100 ---> 0.472
  • 111 ---> 0.023
  • 000 ---> 0.882
in the above list, the minimum distance is 0.023 corresponding to code word 111.
How to get 111(code word with minimum euclidean distance) out from the list as our output in the command window??

답변 (2개)

Sean de Wolski
Sean de Wolski 2011년 6월 23일

0 개 추천

I have no idea how the above is organized but if it's just an nx2 array:
C = [010 0.154
011 .256
100 0.472
111 .023
000 0.882];
[idx,idx] = max(C(:,1));
C(idx,2)
So:
[idx, idx] = max(array1);
array2(idx)
?

댓글 수: 1

mahaveer hanuman
mahaveer hanuman 2011년 6월 23일
both are of different array and each array conssit of 90 rows .So,from that i need only co oresponding least value in above case my output should be 111.

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

Matt Fig
Matt Fig 2011년 6월 23일

0 개 추천

You could make a little function:
function y = mydist(x)
% Takes a three digit binary string argument.
switch x
case '010'
y = 0.154;
case '011'
y = 0.256;
case '100'
y = 0.472;
case '111'
y = 0.023;
case '000'
y = 0.882;
otherwise
y = [];
end
Then when you want to use it:
>> y = mydist('111')
y =
0.0230
>>

댓글 수: 3

mahaveer hanuman
mahaveer hanuman 2011년 6월 23일
010 ---> 0.154
011 ---> 0.256
100 ---> 0.472
111 ---> 0.023
000 ---> 0.882
i have upto 90 arrays so i can't use switch case for all
so only the respect least cooresponding value i need .in above case only output = 111
Matt Fig
Matt Fig 2011년 6월 23일
If you only need one output, then get rid of the SWITCH, and just use an IF statement to check if the input is a match.
if strcmp(x,'111')
y = 0.023;
else
y = [];
end
mahaveer hanuman
mahaveer hanuman 2011년 6월 23일
lets A =[ 1 1 0 after dng some steps i got z=[ 0.2345
1 0 1 1.456
0 0 1 0.0673
. . . .....
. . . ......
. . . .....
1 1 0] 6.987]
both A and Z have 90 rows in each .now for least value of Z i need to take co-responding value as my out put so can u help me.
from above my out is
0 0 1.

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

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

질문:

2011년 6월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by