Represent parameters as other parameters
Show older comments
HI, is there a way in matlab to find t1,t2,d3 represnted by x,y and z
as an example:
3 equations:
1. -cos(t1)*(h2 - d3*cos(t2)) = x
2. h1 + d3*sin(t2) = y
3. sin(t1)*(h2 - d3*cos(t2)) = z
i want to represent t1,t2, and d3 by x,y and z (h1 and h2 are constants)
is there any function that can do that?
Thank You.
by the way the analytic answer is :
t1 = atan2(x/sqrt(x^2+z^2),z/sqrt(x^2+z^2))
t2 = atan((x+h2*sin(t1))/(y-h1))
d3 = (sin(t1)*h2-z)/sin(t2)
2 Comments
madhan ravi
on 30 Jan 2019
syms t1 t2 t3 h1 h2 d3 x y z
e1=-cos(t1)*(h2 - d3*cos(t2)) == x;
e2=h1 + d3*sin(t2) == y;
e3=sin(t1)*(h2 - d3*cos(t2)) == z;
[x,y,z]=solve(e1,e2,e3,x,y,z) %?
Yarden Akaby
on 30 Jan 2019
Answers (1)
Hi,
syms t1 t2 d3 h1 h2 x y z
eq1 = -cos(t1)*(h2 - d3*cos(t2)) == x;
eq2 = h1 + d3*sin(t2) == y;
eq3 = sin(t1)*(h2 - d3*cos(t2)) == z;
eq1 = isolate(eq1, t1)
eq2 = isolate(eq2, d3)
eq3 = isolate(eq3, t2)
Best regards
Stephan
4 Comments
John D'Errico
on 30 Jan 2019
That fails of course, since isolate leaves the other variables in there. So the isolate on t1 leaves t2 in the equation.
eq1 = isolate(eq1, t1)
eq1 =
t1 == pi + acos(x/(h2 - d3*cos(t2)))
In the as correct provided solutions of the questioner, it is the same:
"...by the way the analytic answer is :
t1 = atan2(x/sqrt(x^2+z^2),z/sqrt(x^2+z^2))
t2 = atan((x+h2*sin(t1))/(y-h1))
d3 = (sin(t1)*h2-z)/sin(t2)
..."
So this maybe not a problem?
Yarden Akaby
on 30 Jan 2019
yes, that appears to be a little to hard for symbolic calculations in Matlab. Sure you could read in the documentation and try to get what you want by working for hours, but this is not what is expected. Anyway, there is more than solve command. In your case the "more" is not enough...
But if you know a way to tackle the problem, consider:
syms t1 t2 d3 h1 h2 x y z
eq1 = -cos(t1)*(h2 - d3*cos(t2)) == x;
eq2 = h1 + d3*sin(t2) == y;
eq3 = sin(t1)*(h2 - d3*cos(t2)) == z;
eq1 = isolate(eq1, t1);
eq2 = isolate(eq2, d3);
eq3 = isolate(eq3, t1);
eq4 = eq3/eq1
eq4 = subs(eq4,d3,rhs(eq2))
eq4 = isolate(eq4,t2)
which is a solution to t2 that would help more i guess.
Categories
Find more on Special Values in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!