Filter löschen
Filter löschen

Quick Question: Writing equation with mod function

3 Ansichten (letzte 30 Tage)
Emanuele Joy
Emanuele Joy am 24 Mai 2018
Kommentiert: Guillaume am 24 Mai 2018
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.

Antworten (1)

TAB
TAB am 24 Mai 2018
Bearbeitet: TAB am 24 Mai 2018
z = mod((x + y), 26);
  1 Kommentar
Guillaume
Guillaume am 24 Mai 2018
Note that the brackets around x + y are unnecessary and in my opinion impede readability:
z = mod(x + y, 26);

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by