how to calculate closest points in a row matlab?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
abdul wahab aziz
il 27 Ago 2016
Commentato: Image Analyst
il 27 Ago 2016
i have a row 0.7422 0.0436 1 0.6040 0.057
in this row i need to find closest distance from 3rd col point which is 0.6040 the ans should be 0.7422
2 Commenti
Star Strider
il 27 Ago 2016
The ‘third col point’ is actually 1, not 0.6040 which is the fourth, but the answer is the same regardless.
Image Analyst
il 27 Ago 2016
I'm not sure I understand the question. Do you want to
- find out which element has a value closest to the value of element 3, OR
- find out which pairs of elements have the smallest difference between their values?
Which one? Your subject line seems to indicate #2 but the body of your post seems to ask #1, so which is it? Or is it something else?
Risposta accettata
Star Strider
il 27 Ago 2016
One approach:
V = [0.7422 0.0436 1 0.6040 0.057];
idx = 3;
[~,Vidx] = min(abs(V(idx) - V(V~=V(idx))));
Out = V(Vidx)
Out =
0.7422
0 Commenti
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!