PDA

View Full Version : MATLAB confusion


Alem2000
Feb5-05, 12:09 PM
Hello all, i am trying to write a script file that will only print if R is divisible by D where D=3
I wrote a loop statement with the condition being fix(R/D)=R/D this works fine but there is another way that the book does it. The book uses mod(R,D)=0 as the condition. I tried typing in help mod but the explanation that MATLAB gave was extreamly confusing, can anyone tell me what the command mod(x,y) says....what does the (x,y) mean...thanks in adnvance.

faust9
Feb5-05, 02:00 PM
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.

Alem2000
Feb5-05, 03:37 PM
wow...thanks for the example, it hit the spot!!!!