Filter löschen
Filter löschen

matlab code to find the next highest integer

9 Ansichten (letzte 30 Tage)
pavan sunder
pavan sunder am 5 Dez. 2016
Kommentiert: Walter Roberson am 13 Dez. 2018
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

Antworten (2)

KSSV
KSSV am 5 Dez. 2016
a=[1 2 3 4 8 10 24] ;
b = a(a>6) ;
iwant = b(1)

Jan
Jan am 5 Dez. 2016
a = [1 2 3 4 8 10 24];
r = 6;
b = a(find(a > 6, 1));
  2 Kommentare
shariq khan
shariq khan am 13 Dez. 2018
This is more precise
Walter Roberson
Walter Roberson am 13 Dez. 2018
slightly yes as it will not error if there were no matches .

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by