I am trying to find the explicit solution to this system of non-linear equation, however solve(eqn,vars) doesn't seem to work for this purpose. Am I overseeing something

조회 수: 3 (최근 30일)
syms theta1 theta2(theta1) theta3 theta4 x1 y1 x2 y2 x3 y3 x4 y4
L1 = 7.35;
L2 = 5.7;
L3 = 6.7;
L4 = 6.7;
alpha1 = 6;
xg5 = -2.2;
yg5 = -0.7;
eqn1 = x1 + 0.5*L1*cosd(theta1) - x2 + 0.5*L2*cosd(theta2(theta1)) == 0
eqn2 = y1 + 0.5*L1*sind(theta1) - y2 + 0.5*L2*sind(theta2(theta1)) == 0
eqn3 = x2 + 0.5*L2*cosd(theta2(theta1)) - x3 + 0.5*L3*cosd(theta3) == 0
eqn4 = y2 + 0.5*L2*sind(theta2(theta1)) - y3 + 0.5*L3*sind(theta3) == 0
eqn5 = x3 + 0.5*L3*cosd(theta3) - x4 + 0.5*L4*cosd(theta4) == 0
eqn6 = y3 + 0.5*L3*sind(theta3) - y4 + 0.5*L4*sind(theta4) == 0
eqn7 = x1 + 0.5*(-L1)*cosd(theta1) - 0 == 0
eqn8 = y1 + 0.5*(-L1)*sind(theta1) - 0 == 0
eqn9 = x4 + 0.5*(L4)*cosd(theta4) - xg5 == 0
eqn10 = y4 + 0.5*(L4)*sind(theta4) - yg5 == 0
eqn11 = -theta3 + theta2(theta1) - alpha1 + 180 == 0;
eqns = [eqn1; eqn2; eqn3; eqn4; eqn5; eqn6; eqn7; eqn8; eqn9; eqn10; eqn11]
vars = [theta2(theta1) theta3 theta4 x1 y1 x2 y2 x3 y3 x4 y4];
[stheta2(theta1), stheta3, stheta4, sx1, sy1, sx2, sy2, sx3, sy3, sx4, sy4] = solve(eqns, vars)
  댓글 수: 5
Torsten
Torsten 2023년 5월 1일
편집: Torsten 2023년 5월 1일
Defining one variable as a function of another reduces the number of unknowns to 10. Thus you try to solve a system of 11 equations in 10 unknowns.
Furthermore, "solve" cannot solve systems with functions as unknowns.
You could try to define an independent variable u for theta2(theta1) and solve your system for u,theta1, theta3, theta4, x1, y1, x2, y2, x3, y3, x4, y4. Maybe by chance u can be written as a function of the solution for theta1, but I doubt it.
And my guess is that the 180 in the last equation should be pi, shouldn't it ?
John D'Errico
John D'Errico 2023년 5월 1일
편집: John D'Errico 2023년 5월 1일
I don't think that 180 should be a pi. All of the angles are in degrees, since sind and cosd were used exclusively. That means the units for eqn11 would be degrees, not radians.
But Torsten is also correct, in that you CANNOT solve for an unknown function.

댓글을 달려면 로그인하십시오.

답변 (1개)

Dheeraj
Dheeraj 2023년 8월 16일
Hi,
The Solve function for the system of equation in question doesn’t work as MATLAB solve function doesn’t solve systems with unknown functions.
Instead, you could modify your system of equations as below thus eliminating the unknown function i.e., theta2(theta1) in solve:
syms theta1 theta3 theta4 x1 y1 x2 y2 x3 y3 x4 y4
L1 = 7.35;
L2 = 5.7;
L3 = 6.7;
L4 = 6.7;
alpha1 = 6;
xg5 = -2.2;
yg5 = -0.7;
% Solve for theta2(theta1) using eqn11
theta2_theta1_expr = solve(-theta3 + theta2 - alpha1 + 180, theta2);
% Substitute theta2(theta1) into other equations
eqn1 = x1 + 0.5*L1*cosd(theta1) - x2 + 0.5*L2*cosd(subs(theta2_theta1_expr, theta2, theta2)) == 0;
eqn2 = y1 + 0.5*L1*sind(theta1) - y2 + 0.5*L2*sind(subs(theta2_theta1_expr, theta2, theta2)) == 0;
eqn3 = x2 + 0.5*L2*cosd(subs(theta2_theta1_expr, theta2, theta2)) - x3 + 0.5*L3*cosd(theta3) == 0;
eqn4 = y2 + 0.5*L2*sind(subs(theta2_theta1_expr, theta2, theta2)) - y3 + 0.5*L3*sind(theta3) == 0;
eqn5 = x3 + 0.5*L3*cosd(theta3) - x4 + 0.5*L4*cosd(theta4) == 0;
eqn6 = y3 + 0.5*L3*sind(theta3) - y4 + 0.5*L4*sind(theta4) == 0;
eqn7 = x1 + 0.5*(-L1)*cosd(theta1) - 0 == 0;
eqn8 = y1 + 0.5*(-L1)*sind(theta1) - 0 == 0;
eqn9 = x4 + 0.5*(L4)*cosd(theta4) - xg5 == 0;
eqn10 = y4 + 0.5*(L4)*sind(theta4) - yg5 == 0;
% Combine all equations
eqns = [eqn1, eqn2, eqn3, eqn4, eqn5, eqn6, eqn7, eqn8, eqn9, eqn10];
% Solve the equations for the variables
solutions = solve(eqns, [theta1, theta3, theta4, x1, y1, x2, y2, x3, y3, x4, y4]);
Refer this document for better understanding.

카테고리

Help CenterFile Exchange에서 Linear Algebra에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by