Quick Question: Writing equation with mod function

2 ビュー (過去 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 Center および File ExchangeShifting and Sorting Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by