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 CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by