Results 1 to 4 of 4

Math Help - Matlab Help closest next number

  1. #1
    Newbie
    Joined
    Mar 2010
    Posts
    2

    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
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by lediom View Post
    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
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Mar 2010
    Posts
    2
    oh sorry i meant to say spit back 5.2 not 5. is there still a way to do this?
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by lediom View Post
    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
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Replies: 2
    Last Post: December 3rd 2010, 03:45 AM
  2. if number closest to zero does sign matter?
    Posted in the Algebra Forum
    Replies: 7
    Last Post: July 28th 2010, 03:05 AM
  3. Matlab - Random Number between 1 .. n
    Posted in the Math Software Forum
    Replies: 2
    Last Post: March 16th 2010, 05:55 PM
  4. MATLAB - Random Number Generation
    Posted in the Math Software Forum
    Replies: 4
    Last Post: February 18th 2009, 07:03 AM
  5. Matlab: Number formating
    Posted in the Math Software Forum
    Replies: 1
    Last Post: April 7th 2008, 09:39 AM

Search Tags


/mathhelpforum @mathhelpforum