difference between rem and mod functions?
17 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Rakan Alharthi
el 14 de Mzo. de 2022
Comentada: Stephen23
el 14 de Mzo. de 2022
im confused , What is the difference between rem and mod functions? can you give a simple example?
Respuesta aceptada
Stephen23
el 14 de Mzo. de 2022
Editada: Stephen23
el 14 de Mzo. de 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.
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
