Empty sym: 0-by-1 in solving a system of equations

19 Ansichten (letzte 30 Tage)
Mahsa Babaee
Mahsa Babaee am 1 Nov. 2021
Kommentiert: Mahsa Babaee am 10 Nov. 2021
Hi friends
I am trying to solve the following symbolic system of equations:
While are parameters. And I want to find in terms of .
I used the code as below but I faced an error as :
ans =
Empty sym: 0-by-1
My code is:
syms N1 N2 N3 M1 M2 M3 D21 D32 S1 S2 S3
eqn=[M1==1,N1*cos(0)==0, M1*sin(S1)+N1*cos(S1)==N2*cos(0), M2*sin(S2)+N2*cos(S2)==N3*cos(0), M3*sin(S3)+N3*cos(S3)==0, M1*cos(S1)-N1*sin(S1)==M2*D21*cos(0), M2*cos(S2)-N2*sin(S2)==M3*D32*cos(0)];
A=solve(eqn,[M1 M2 M3 N1 N2 N3]);
A.M1
A.M2
A.M3
A.N1
A.N2
A.N3
Could you please guide me how can I solve the problem?
Thanks in advance.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 1 Nov. 2021
You have 7 equations that you want to solve for 6 unknown. That is not generally possible.
solve the first 6 equations for the 6 unknown and subs() the results into the last eqn. The result will effectively be a constraint between the 5 variables.
You can solve() the constraint for any 1 variable. Solving for either D variable gives a comparatively uncomplicated result. Solving for S1 or S2 give single results that are complicated involving log and complex numbers. Solving for S3 gives two families of complicated solutions similar to the other S ones but also having 2*pi*k as a factor for integer k (so a periodic solution)
But if the D and S are inputs then the overall system has no solution unless the 7th equation happens to hold.
  3 Kommentare
Walter Roberson
Walter Roberson am 9 Nov. 2021
Empty sym does not necessarily mean that there is no solution at all.
If you try to solve for fewer variables than you have equations, it is common for MATLAB to give up, even if there is a solution. For
syms x y
sol = solve([x + y == 5, x + 2*y == 8], x)
sol = Empty sym: 0-by-1
but
syms x y
sol = solve([x + y == 5, x + 2*y == 8], [x, y])
sol = struct with fields:
x: 2 y: 3
The problem was not lack of solutions; MATLAB just does not know how to handle that situation.
There are also situations, especially involving non-linear equations, where MATLAB cannot find a solution when it works to the accuracy of the current number of digits, but there might mathematically be a solution. With the default number of digits being 32 and with MATLAB using 5 extra "guard" digits, it might be the case with a nonlinear function that a particular potential x is gives a result "notably" below a target, and that the next representable number 1 part in 10^37 different, gives a result "notably" below the target. So sometimes you just need to increase the number of digits to get a solution.
(That said, I have worked with some nonlinear equations for which 50000 digits was not enough to come to a conclusion. Cases where symbolic software said "This equation can be rewritten as this other equation that doesn't look much the same at all", and I doubted it and tried to prove or disprove it mathematically, without success...)
Mahsa Babaee
Mahsa Babaee am 10 Nov. 2021
Thank you so much. Your explanations are really helpful.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Symbolic Math Toolbox finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by