symbolic system of equations matlab
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hello,
I need help with this task!
I did not get a solution to system 1. All i had: Empty sym: 0-by-1
But when i assign values to X,Y and Z (like in 2) it works. I need a symbolic solution as a function of X,Y and Z.
**************************1********************************
syms X Y Z Theta1 Theta2 Theta3
F = zeros(3,1);
eqn1 = F(1) == (cos(Theta2)+cos(Theta3-Theta2))*sin(-Theta1) - X;
eqn2 = F(2)== (cos(Theta2)+cos(Theta3-Theta2))*cos(Theta1) -Y;
eqn3 = F(3)== 1+sin(-Theta2)+sin(Theta3-Theta2)-Z;
[Theta1,Theta2,Theta3] = solve(eqn1,eqn2,eqn3,Theta1,Theta2,Theta3);
**************************2********************************
syms X Y Z Theta1 Theta2 Theta3
F = zeros(3,1);
eqn1 = F(1) == (cos(Theta2)+cos(Theta3-Theta2))*sin(-Theta1) - 0;
eqn2 = F(2)== (cos(Theta2)+cos(Theta3-Theta2))*cos(Theta1) -0;
eqn3 = F(3)== 1+sin(-Theta2)+sin(Theta3-Theta2)-3;
[Theta1,Theta2,Theta3] = solve(eqn1,eqn2,eqn3,Theta1,Theta2,Theta3);
0 comentarios
Respuestas (2)
Doddy Kastanya
el 12 de En. de 2021
You might want to check out the information in the following link https://www.mathworks.com/help/symbolic/solve-a-system-of-algebraic-equations.html .
1 comentario
Walter Roberson
el 12 de En. de 2021
Editada: Walter Roberson
el 12 de En. de 2021
syms X Y Z Theta1 Theta2 Theta3
F = zeros(3,1);
eqn1 = F(1) == (cos(Theta2)+cos(Theta3-Theta2))*sin(-Theta1) - X;
eqn2 = F(2)== (cos(Theta2)+cos(Theta3-Theta2))*cos(Theta1) -Y;
eqn3 = F(3)== 1+sin(-Theta2)+sin(Theta3-Theta2)-Z;
E = [eqn1, eqn2, eqn3];
vars = [Theta1,Theta2,Theta3]
sol1 = solve(E(1), vars(1))
E2 = simplify( rewrite(subs(E(2:end), vars(1), sol1(1)), 'sinhcosh'),'steps', 50)
sol3 = solve(E2(2), vars(2))
E3 = simplify(rewrite(subs(E2([1 3:end]), vars(2), sol3(1)),'sinhcosh'),'steps',1)
sol2 = solve(E3(1), vars(3), 'returnconditions', true)
sol2.Theta3
sol2.conditions
cs = simplify(sol2.conditions, 'steps', 25)
And then start analyzing sol2.conditions .
You can potentially get further by assuming that X, Y, and Z are real-valued.
cc = children(cs);
eqz = simplify(lhs(cc{1})-rhs(cc{1}), 'steps', 10)
z1 = solve(eqz, Z, 'returnconditions', true)
That is empty.. does that mean that the two can never be equal and so the first condition is always true?
Xtry = randi([-9 9])
Ytry = randi([-9 9])
eqtry = simplify(subs(eqz, {X, Y}, {Xtry, Ytry}), 'steps', 10)
solve(eqtry, Z, 'returnconditions', true)
fplot(eqtry, [-10 10])
limit(eqtry, Z, inf)
So there would seem to be equality at infinity, which implies inequality otherwise, which implies the first condition does hold. But what about 0 ?
eqtry = simplify(subs(eqz, {X, Y}, {0, 0}), 'steps', 10)
solve(eqtry, Z, 'returnconditions', true)
fplot(eqtry, [-10 10])
fplot(imag(eqtry), [-1 1])
fplot(imag(eqtry), [1 3])
Nope, those generate complex values in part of the range, but never equal 0
subs(eqtry, Z, 1)
The imaginary part of that is 0, and the real part is negative whereas the real part of the previous eqtry plots were positive, but there is no zero crossing over real-valued Z. It might be worth investigating more to determine if there is an imaginary Z.
0 comentarios
Ver también
Categorías
Más información sobre Conversion Between Symbolic and Numeric en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!