How to fix the sym/solve error

18 views (last 30 days)
Randy Chen
Randy Chen on 26 Oct 2021
Answered: Paul on 26 Oct 2021
I get the following error from my code:
z = [-6.41 -12.4 2.143 102];
r = [13.58 15.7636 12.96 46.6];
syms A B C D;
eq1 = A*r(1)^2+B*z(1)+C*r(1)+D ==0;
eq2 = A*r(2)^2+B*z(2)+C*r(2)+D ==0;
eq3 = A*r(3)^2+B*z(3)+C*r(3)+D ==0;
eq4 = A*r(4)^2+B*z(4)+C*r(4)+D ==0;
solve([eq1,eq2,eq3,eq4],[A,B,C,D])
>> solve([eq1,eq2,eq3,eq4],[A,B,C,D])
Error using sym/solve (line 89)
Error using maplemex
Error, (in MTM:-solve) Vector[row](4, [0,0,0,0], datatype = integer[1]) is not valid equation or expression
And when I tried to display the path of the symbolic solve, here is the result:
>> which -all solve
D:\Softwares\toolbox\maple\solve.m
D:\Softwares\toolbox\maple\@sym\solve.m % sym method
D:\Softwares\toolbox\symbolic\symbolic\@sym\solve.m % sym method
How should I fix this issue?

Accepted Answer

Paul
Paul on 26 Oct 2021
What version are you using? Seems to work ok here, but w/o any references to Maple.
which -all solve
/MATLAB/toolbox/symbolic/symbolic/@sym/solve.m % sym method
z = [-6.41 -12.4 2.143 102];
r = [13.58 15.7636 12.96 46.6];
syms A B C D;
eq1 = A*r(1)^2+B*z(1)+C*r(1)+D ==0;
eq2 = A*r(2)^2+B*z(2)+C*r(2)+D ==0;
eq3 = A*r(3)^2+B*z(3)+C*r(3)+D ==0;
eq4 = A*r(4)^2+B*z(4)+C*r(4)+D ==0;
sol = solve([eq1,eq2,eq3,eq4],[A,B,C,D])
sol = struct with fields:
A: 0 B: 0 C: 0 D: 0
By inspection, we see that solve returned the trivial solution. We can also verify it's the only solution
M = [r(:).^2 z(:) r(:) ones(4,1)];
null(M)
ans = 4×0 empty double matrix

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!