MATLAB Answers

0

matlab code to find the next highest integer

Asked by pavan sunder on 5 Dec 2016
Latest activity Commented on by Walter Roberson
on 13 Dec 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

  0 Comments

Sign in to comment.

Tags

2 Answers

Answer by KSSV
on 5 Dec 2016

a=[1 2 3 4 8 10 24] ;
b = a(a>6) ;
iwant = b(1)

  0 Comments

Sign in to comment.


Answer by Jan
on 5 Dec 2016

a = [1 2 3 4 8 10 24];
r = 6;
b = a(find(a > 6, 1));

  2 Comments

This is more precise
slightly yes as it will not error if there were no matches .

Sign in to comment.