How to find the input value when outputting the maximum value
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
[mi] = [dab,dac,dad,dbc,dbd,dcd];
length = max(mi);
The coordinates of the four points A, B, C, and D are known. I have calculated the distance between the two points through pdist2(). I used max() to get the maximum value of these distances. My current requirement is to convert the maximum The two points are connected by a plot() line, so how can I know the coordinates of the two points of the maximum value?
0 commentaires
Réponse acceptée
Walter Roberson
le 30 Avr 2022
Modifié(e) : Walter Roberson
le 30 Avr 2022
[max_length, maxidx] = max(mi);
switch maxidx
case 1
coords = {A, B};
case 2
coords = {A, C};
case 3
coords = {A, D};
case 4
coords = {B, C};
case 5
coords = {B, D};
case 6
coords = {C, D};
otherwise
error('strange maximum index!')
end
... It would have been easier to work with the array returned by pdist2() directly.
all_coords = {A, B, C, D};
[max_length, maxidx] = max( reshape(triu(Distance_Matrix), [], 1 );
[R,C] = ind2sub( size(Distance_Matrix), maxidx );
coords = {all_coords{R}, all_coords{C}};
2 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Predictive Maintenance Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!