Least possible value for a modulo with given remainders
Show older comments
Hello guys. Im just asking how do you code a program that gets the LEAST value of a given modulo and remainder. Say example
Z = [3 4 5]
R = [2 1 4]
The inputs will give an output that gives the LEAST possible value for the given. So the answer to the above is 29.
3 Comments
John D'Errico
on 8 Dec 2015
Edited: John D'Errico
on 8 Dec 2015
In general, you would use the chinese remainder theorem for problems of this ilk. Your question is not terribly clear though. Are you asking to solve for x, such that
mod(x,[3 4 5]) == [2 1 4]
You code it by writing the code. You COULD use intlinprog. if you think about the meaning of those modular equations.
mod(x,3) == 2
is equivalent to
x == 3*u1 + 2
likewise for the others. Then can you solve for x,u1,u2,u3, such that x is minimized, is non-negative, AND is integer, along with u1,u2,u3?
help intlinprog
Riven Yvet
on 9 Dec 2015
Riven Yvet
on 9 Dec 2015
Answers (0)
Categories
Find more on Image Arithmetic in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!