How to check divisibility?

335 ビュー (過去 30 日間)
Caped Crusader
Caped Crusader 2013 年 1 月 20 日
回答済み: Jitesh Kumar 2018 年 9 月 25 日
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.

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 1 月 20 日
編集済み: Azzi Abdelmalek 2013 年 1 月 20 日
a=3;
b=2;
out=~rem(a,b)*a/b
  4 件のコメント
Caped Crusader
Caped Crusader 2013 年 1 月 20 日
Thanks ,it works!
Caped Crusader
Caped Crusader 2013 年 1 月 20 日
However, I used rem(a,b) format after checking the help files and it worked. Anyway thank you very much.

サインインしてコメントする。

その他の回答 (1 件)

Jitesh Kumar
Jitesh Kumar 2018 年 9 月 25 日
a=5; b=1; rem(a,b)=4

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by