Borrar filtros
Borrar filtros

How to find a maximum number not considered minus sign?

15 visualizaciones (últimos 30 días)
Jothi
Jothi el 17 de Jul. de 2014
Comentada: Bruno Luong el 28 de Mzo. de 2021
Sir,
I want find the maximum number in the given array.
But, I am not considered negative sign.
for example, a=[4, 3, -8],
output is = -8. Because 8 is the maximum number.
how I get this output.
thank you.

Respuesta aceptada

Andrei Bobrov
Andrei Bobrov el 17 de Jul. de 2014
a = [4, 3, -8];
[~,ii] = max(abs(a));
out = a(ii);
  2 comentarios
Poorva
Poorva el 28 de Mzo. de 2021
Sir, how to do the same in a matrix
Bruno Luong
Bruno Luong el 28 de Mzo. de 2021
The same command should work on matrix to.

Iniciar sesión para comentar.

Más respuestas (1)

Matz Johansson Bergström
Matz Johansson Bergström el 17 de Jul. de 2014
It sounds like you want to find the max absolute value of a vector. This can be accomplished simply by taking the absolute value and remember the index to that value and picking it out:
a = [1,4,5,-8,3];
[val, ind] = max(abs(a));
a(ind)
  2 comentarios
Matz Johansson Bergström
Matz Johansson Bergström el 17 de Jul. de 2014
Ah, Andrei beat me to it ;-)
Jothi
Jothi el 17 de Jul. de 2014
i accept this answer also.
thank you sir.

Iniciar sesión para comentar.

Categorías

Más información sobre Wavelet Toolbox en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by