Empty sym: 0-by-1 in solving a system of equations
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Mahsa Babaee
el 1 de Nov. de 2021
Comentada: Mahsa Babaee
el 10 de Nov. de 2021
Hi friends
I am trying to solve the following symbolic system of equations:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/785343/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/785348/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/785353/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/785358/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/785363/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/785368/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/785373/image.png)
While
are parameters. And I want to find
in terms of
.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/785378/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/785383/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/785388/image.png)
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.
0 comentarios
Respuesta aceptada
Walter Roberson
el 1 de Nov. de 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 comentarios
Walter Roberson
el 9 de Nov. de 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)
but
syms x y
sol = solve([x + y == 5, x + 2*y == 8], [x, y])
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...)
Más respuestas (0)
Ver también
Categorías
Más información sobre Symbolic Math Toolbox en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!