How to find the input value when outputting the maximum value
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
文辉 沈
el 30 de Abr. de 2022
Comentada: 文辉 沈
el 30 de Abr. de 2022
[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 comentarios
Respuesta aceptada
Walter Roberson
el 30 de Abr. de 2022
Editada: Walter Roberson
el 30 de Abr. de 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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Predictive Maintenance Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!