matlab code to find the next highest integer

suppose i have a array a=[1 2 3 4 8 10 24] i have a random value for ex r=6;
i have to find the next highest integer to 6 in the given array i.e the output should be 8.
kindly help me with a matlab code

Respuestas (2)

Jan
Jan el 5 de Dic. de 2016
a = [1 2 3 4 8 10 24];
r = 6;
b = a(find(a > 6, 1));

2 comentarios

shariq khan
shariq khan el 13 de Dic. de 2018
This is more precise
Walter Roberson
Walter Roberson el 13 de Dic. de 2018
slightly yes as it will not error if there were no matches .

Iniciar sesión para comentar.

Categorías

Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 5 de Dic. de 2016

Comentada:

el 13 de Dic. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by