Borrar filtros
Borrar filtros

Quick Question: Writing equation with mod function

2 visualizaciones (últimos 30 días)
Emanuele Joy
Emanuele Joy el 24 de Mayo de 2018
Comentada: Guillaume el 24 de Mayo de 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.

Respuestas (1)

TAB
TAB el 24 de Mayo de 2018
Editada: TAB el 24 de Mayo de 2018
z = mod((x + y), 26);
  1 comentario
Guillaume
Guillaume el 24 de Mayo de 2018
Note that the brackets around x + y are unnecessary and in my opinion impede readability:
z = mod(x + y, 26);

Iniciar sesión para comentar.

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by