Quick Question: Writing equation with mod function
显示 更早的评论
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 个)
z = mod((x + y), 26);
1 个评论
Guillaume
2018-5-24
Note that the brackets around x + y are unnecessary and in my opinion impede readability:
z = mod(x + y, 26);
类别
在 帮助中心 和 File Exchange 中查找有关 Shifting and Sorting Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!