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

5 次查看(过去 30 天)
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?

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Symbolic Math Toolbox 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by