필터 지우기
필터 지우기

Quick Question: Writing equation with mod function

조회 수: 3 (최근 30일)
Emanuele Joy
Emanuele Joy 2018년 5월 24일
댓글: Guillaume 2018년 5월 24일
I'm trying to interpret this equation: z = (x + y) % 26
to MATLAB formatting. The % is modulus division, so I know I'm supposed to use the mod function, but I'm not too certain how to. Is this correct?
z = (x + y)*mod(26, 0);
I read the documentation on mod functions but I'm still not sure what it does. Clarification would be appreciated.

답변 (1개)

TAB
TAB 2018년 5월 24일
편집: TAB 2018년 5월 24일
z = mod((x + y), 26);
  댓글 수: 1
Guillaume
Guillaume 2018년 5월 24일
Note that the brackets around x + y are unnecessary and in my opinion impede readability:
z = mod(x + y, 26);

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by