difference between rem and mod functions?

34 Ansichten (letzte 30 Tage)
Rakan Alharthi
Rakan Alharthi am 14 Mär. 2022
Kommentiert: Stephen23 am 14 Mär. 2022
im confused , What is the difference between rem and mod functions? can you give a simple example?

Akzeptierte Antwort

Stephen23
Stephen23 am 14 Mär. 2022
Bearbeitet: Stephen23 am 14 Mär. 2022
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 Kommentare
Rakan Alharthi
Rakan Alharthi am 14 Mär. 2022
thank you so much !
Stephen23
Stephen23 am 14 Mär. 2022
@Rakan Alharthi : my pleasure! Please remember to accept my answer if it helped you.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Mathematics finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by