Solving a system of equation in terms of an unknown.
4 views (last 30 days)
Show older comments
Mustafa Cüneyt Sevinç
on 20 May 2020
Answered: Mustafa Cüneyt Sevinç
on 23 May 2020
Hi, I'm new here and quite new in MatLab too. So I have a question about an equation sistem consisting of 4 equations and having 5 (tet1, tet2, tet3, x, q) unknowns.. I'm trying to solve 4 of these unknowns (tet1, tet2, tet3, x) in terms of the other one (q). I've written a code, it returns an error in like 30 mins.
Here is the code:
clear
close all
clc
alp = 150;
bet = 18;
a = 0.0125;
b = 0.035;
c = 0.0147;
d = 0.043;
h = 0.0195;
m = 0.0113;
n = 0.0344;
syms x tet1 tet2 tet3 q;
eq(1) = m + d*cos(tet1+bet) - b*cos(tet3) - a*cos(q) == 0;
eq(2) = n + d*sin(tet1+bet) - b*sin(tet3) - a*sin(q) == 0;
eq(3) = x*cos(tet1) + h*cos(tet2) - c*cos(180-alp+tet3) - d*cos(tet1+bet) == 0;
eq(4) = x*sin(tet1) + h*sin(tet2) - c*sin(180-alp+tet3) + d*sin(tet1+bet) == 0;
Sol1 = solve(eq,[x tet1 tet2 tet3]);
What am I missing? What should I change in the code. Thank you in advance for the help.
1 Comment
Walter Roberson
on 20 May 2020
Using Maple, I am able to get solutions in terms of q, by solving for x, tet1, tet3, then tet2 . There are two basic solution families. However, the expressions for tet2 in terms of q are over 19000 characters in each of the families.
Note that you are trying to derive exact solutions to equations involving floating point coefficients. That is not justifiable. For example, in science, c = 0.0147 means that c is some value in the range [147/1000 - 5/10000, 147/1000 + 5/10000) -- and if you do not know the exact value of c, then how could you justify a 20 Kb long exact formula involving some nominal value of c in that range ?
Accepted Answer
Ameer Hamza
on 20 May 2020
Your system of equations is very nonlinear, involving several trigonometric functions, so it is unlikely that it has a closed-form solution. You can solve it for a particular value of 'q' and get a numeric solution. For example, this code solves the equations for q=0.5
clear
close all
clc
alp = 150;
bet = 18;
a = 0.0125;
b = 0.035;
c = 0.0147;
d = 0.043;
h = 0.0195;
m = 0.0113;
n = 0.0344;
syms x tet1 tet2 tet3 q;
eq(1) = m + d*cos(tet1+bet) - b*cos(tet3) - a*cos(q) == 0;
eq(2) = n + d*sin(tet1+bet) - b*sin(tet3) - a*sin(q) == 0;
eq(3) = x*cos(tet1) + h*cos(tet2) - c*cos(180-alp+tet3) - d*cos(tet1+bet) == 0;
eq(4) = x*sin(tet1) + h*sin(tet2) - c*sin(180-alp+tet3) + d*sin(tet1+bet) == 0;
Sol1 = vpasolve(subs(eq, q, 0.5),[x tet1 tet2 tet3]);
0 Comments
More Answers (1)
See Also
Categories
Find more on Boundary Conditions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!