MATLAB Answers


How to check divisibility?

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.

1 Answer

Answer by Azzi Abdelmalek
on 20 Jan 2013
Edited by Azzi Abdelmalek
on 20 Jan 2013
 Accepted answer




is fine

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

Thanks ,it works!

However, I used rem(a,b) format after checking the help files and it worked. Anyway thank you very much.

Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!