# Matlab Help closest next number

• Mar 15th 2010, 06:30 AM
lediom
Matlab Help closest next number
Hi my project is bases on stress analysis.
i have a bunch on standard numbers and I'm calculating and i get a non-standard number. I want Matlab to spit back to me the next available number towards +infinity
example
x=[1.5 , 2.2 , 3.1 , 4.2 , 5.2 , 6.6 , 7.2]
y=4.3

i would like Matlab to spit back to me 5 not 4.

is there anyone that can help me with this?
Thank you
• Mar 15th 2010, 12:41 PM
CaptainBlack
Quote:

Originally Posted by lediom
Hi my project is bases on stress analysis.
i have a bunch on standard numbers and I'm calculating and i get a non-standard number. I want Matlab to spit back to me the next available number towards +infinity
example
x=[1.5 , 2.2 , 3.1 , 4.2 , 5.2 , 6.6 , 7.2]
y=4.3

i would like Matlab to spit back to me 5 not 4.

is there anyone that can help me with this?
Thank you

ceil(y)

CB
• Mar 15th 2010, 02:13 PM
lediom
oh sorry i meant to say spit back 5.2 not 5. is there still a way to do this?
• Mar 15th 2010, 08:50 PM
CaptainBlack
Quote:

Originally Posted by lediom
oh sorry i meant to say spit back 5.2 not 5. is there still a way to do this?

x(sum(y>x)+1)

CB