How to fix the sym/solve error

조회 수: 18 (최근 30일)
Randy Chen
Randy Chen 2021년 10월 26일
답변: Paul 2021년 10월 26일
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?

채택된 답변

Paul
Paul 2021년 10월 26일
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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Conversion Between Symbolic and Numeric에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by