필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

How can i get almost similar row from amatrix

조회 수: 1 (최근 30일)
Shibla Kp
Shibla Kp 2018년 2월 9일
마감: MATLAB Answer Bot 2021년 8월 20일
I have a row
h=[.9 .5 .4 .3]
and matrix q where q is 4by4 matrix
q=[0.8997 0.1997 0.4985 -0.6996; 0.9912 0.2203 0.5516 -0.7693;
0.9980 0.2219 0.5543 -0.7748; 0.9987 0.2235 0.5556 -0.7791]
how to compute a row which is the most similar row of h in matlab.

답변 (1개)

Jos (10584)
Jos (10584) 2018년 2월 9일
You have to define "similar" more strictly! Here I have take the norm as the similarity measure, but there are other alternatives
% some data
q = randi(5,10,4)
h = randi(5,1,4)
% q(2,:) = h % uncomment to check that minRow will be this row of q
% engine
simFun = @(x) norm(x-h,2) % similarity measure between x and h
simM = arrayfun(@(k) simFun(q(k,:)),1:size(q,1)) % loop over each row of q
[minVal, minRow] = min(simM)
You could put all this in a single line (which is harder to understand and debug).

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by