MATLAB Answers

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

조회 수: 3(최근 30일)
Chenguang Yan
Chenguang Yan 2021년 5월 9일
편집: Chenguang Yan 2021년 5월 9일
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개)

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by