How to solve a system of equations which contains mod() function?

4 views (last 30 days)
eqn represents a system of equations to be solved.
x = sym('x',[1 7],'integer');
assumeAlso(x>=0);
c = [1 2 1 -2 +2 0 -3;...
-2 1 -2 -2 3 -2 -2;...
0 -2 1 1 2 -2 -2;...
0 0 1 1 -2 3 -3;...
-3 0 -1 2 1 -2 3;...
2 3 2 -3 0 1 1;...
-2 -2 -1 -3 0 3 1].';
% a system of equations to be solved
eqn = mod([5; 1; 0; 2; 0; 5; 2]+sum(x.*c,2),10) == 4*ones([7 1])
% The solve() function can't solve this problem correctly
solve(eqn,x,"PrincipalValue",true)
% At least one solution exists
subs(eqn,x,[1 2 3 0 0 3 2])
It seems that solve() function can't solve a system of equations which contains mod() function, is there any other ways to solve eqn in MATLAB?

Answers (0)

Categories

Find more on Symbolic Math Toolbox in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!