Finding the highest mountain peak
Mostrar comentarios más antiguos
How might i find the highest mountain peak, and its name, from a defined set of named mountains?
I have data for a set of 10 mountains as 4 matrices.
[X] and [Y] are single row and column matrices defining distances along orthogonal horizontal coordinates.
[Z] is a 3D matrix (:,:,i) containing corresponding x,y height values and an index i=1:10 to define the mountain set.
[Name] is a 10 element 1D text matrix of of the mountain names.
Using a for loop I can plot the surfaces, find the peaks of each mountain and their names:
surf(X,Y,Z(:,:,i))
maximum=max(max(Z(:,:,i)))
Name(i)
How might i find the overall highest peak, and its name in one hit (without the loop)?
Respuesta aceptada
Más respuestas (2)
[val,idx] = max(Z,[],3) ;
Get the maximum along third dimension, idx gives you the thirs index where max occurs. Now find the max of val, get it's index.
Or you ccan also use.
A = rand(3,3,3);
[M,I] = max(A(:));
[I_row, I_col, I_page] = ind2sub(size(A),I)
1 comentario
Brantosaurus
el 30 de Sept. de 2022
Brantosaurus
el 29 de Sept. de 2022
0 votos
Comunidades de usuarios
Más respuestas en ThingSpeak Community
Categorías
Más información sobre MATLAB Mobile Fundamentals en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!