difference between rem and mod functions?

18 ビュー (過去 30 日間)
Rakan Alharthi
Rakan Alharthi 2022 年 3 月 14 日
コメント済み: Stephen23 2022 年 3 月 14 日
im confused , What is the difference between rem and mod functions? can you give a simple example?

採用された回答

Stephen23
Stephen23 2022 年 3 月 14 日
編集済み: Stephen23 2022 年 3 月 14 日
and the MOD and REM documentation:
They both give exactly the same outputs if their input arguments are positive. If their input arguments are negative, then their outputs can differ. This is very easy to demonstrate:
V = -10:0.25:10;
M = [mod(V(:),3),rem(V(:),3)];
plot(V(:),M)
legend('mod','rem','location','best')
You could loosely think of REM as answering the question "what remains after I divide by Q", whereas MOD is completely periodic. Neither is more "correct" or "better", each one is useful in different situtations.
  2 件のコメント
Rakan Alharthi
Rakan Alharthi 2022 年 3 月 14 日
thank you so much !
Stephen23
Stephen23 2022 年 3 月 14 日
@Rakan Alharthi : my pleasure! Please remember to accept my answer if it helped you.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by