Results 1 to 3 of 3

Math Help - Matlab Integer Value

  1. #1
    Newbie
    Joined
    Aug 2009
    Posts
    9

    Matlab Integer Value

    Hello!

    I'm trying to calculate the factorial of a number, but I don't know which command to use to test if the input variable is an integer.

    I tried using the isinteger command, but it returns ans = 0 when you enter both decimal values and positive integers.

    Is there any other command I can use that returns true (ans = 1) for positive integer values and false (ans = 0) for non-integer values? I've been trying to look this up but I can't find it. >_>

    Thank you in advance to anybody who helps!

    --Gina
    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 ginarific View Post
    Hello!

    I'm trying to calculate the factorial of a number, but I don't know which command to use to test if the input variable is an integer.

    I tried using the isinteger command, but it returns ans = 0 when you enter both decimal values and positive integers.

    Is there any other command I can use that returns true (ans = 1) for positive integer values and false (ans = 0) for non-integer values? I've been trying to look this up but I can't find it. >_>

    Thank you in advance to anybody who helps!

    --Gina
    x==floor(x)

    CB
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Aug 2009
    Posts
    9
    Oh, very clever! Thank you!
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Replies: 13
    Last Post: August 3rd 2010, 04:16 AM
  2. Replies: 1
    Last Post: March 5th 2010, 04:11 AM
  3. Integer roots of integer polynomials
    Posted in the Discrete Math Forum
    Replies: 1
    Last Post: December 3rd 2009, 01:39 PM
  4. Raise integer to positive integer power
    Posted in the Algebra Forum
    Replies: 2
    Last Post: May 21st 2009, 01:20 PM
  5. [SOLVED] even integer and odd integer
    Posted in the Algebra Forum
    Replies: 2
    Last Post: October 1st 2008, 09:35 PM

Search Tags


/mathhelpforum @mathhelpforum