Asked by Caped Crusader
on 20 Jan 2013

Hi, I need to check whether two numbers are divisible or not. But how can I do that in Matlab? e.g. Matlab gives 1.5 for 3/2 but I need to get 3/2 = 0 and 4/2 =2.

*No products are associated with this question.*

Answer by Azzi Abdelmalek
on 20 Jan 2013

Edited by Azzi Abdelmalek
on 20 Jan 2013

Accepted answer

a=3; b=2; out=~rem(a,b)*a/b

Show 1 older comment

Azzi Abdelmalek
on 20 Jan 2013

~mod(a,b)

is fine

**mod** and **rem** are the same when a and b have the same sign

Caped Crusader
on 20 Jan 2013

Opportunities for recent engineering grads.

## 0 Comments