1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

MATLAB confusion

  1. Feb 5, 2005 #1
    Hello all, i am trying to write a script file that will only print if [tex]R[/tex] is divisible by [tex]D[/tex] where [tex]D=3[/tex]
    I wrote a loop statement with the condition being [tex]fix(R/D)=R/D[/tex] this works fine but there is another way that the book does it. The book uses [tex]mod(R,D)=0[/tex] as the condition. I tried typing in [tex]help mod[/tex] but the explanation that MATLAB gave was extreamly confusing, can anyone tell me what the command [tex]mod(x,y)[/tex] says....what does the [tex](x,y)[/tex] mean...thanks in adnvance.
  2. jcsd
  3. Feb 5, 2005 #2
    mod is the modulus of command. A modulus is essentially the remainder of a division process. Here's a few examples:

    4/2=2 R=0--2 goes evenly into 4 thus there is no remainder.

    so, mod(4,2) would give a result of 0

    9/4=2 R=1--4 goes into 9 twice leaving a remainder of 1

    so, mod(9,4) would give a result of 1.

    Mod commands are common to most (I can't think of a language that doesn't include this command though different syntax is used) and are very powerful/useful tools.

    Hope this helped. Good luck.
  4. Feb 5, 2005 #3
    wow...thanks for the example, it hit the spot!!!!
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?

Similar Discussions: MATLAB confusion
  1. Confused by Maple (Replies: 2)

  2. Matlab and physics (Replies: 3)

  3. MATLAB problem (Replies: 1)

  4. MATLAB histogram (Replies: 3)