difference between rem and mod functions?
18 ビュー (過去 30 日間)
古いコメントを表示
im confused , What is the difference between rem and mod functions? can you give a simple example?
採用された回答
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.
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
