Represent parameters as other parameters

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 件のコメント

madhan ravi
madhan ravi 2019 年 1 月 30 日
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
Yarden Akaby 2019 年 1 月 30 日
Hi ravi, thanks but i think you ment:
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;
[t1,t2,d3]=solve(e1,e2,e3,t1,t2,d3) %% i change this line
[t1,t2,d3]=solve(e1,e2,e3,t1,t2,d3) because i wanted to find the analytic solution,
but when i input this in matlab it write:
Warning: Unable to find explicit solution. For options, see help.
> In solve (line 317)
do you know how can i fix it?
thank you.

サインインしてコメントする。

回答 (1 件)

Stephan
Stephan 2019 年 1 月 30 日
編集済み: Stephan 2019 年 1 月 30 日

0 投票

Hi,
you can use isolate function:
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 件のコメント

John D'Errico
John D'Errico 2019 年 1 月 30 日
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)))
Stephan
Stephan 2019 年 1 月 30 日
編集済み: Stephan 2019 年 1 月 30 日
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
Yarden Akaby 2019 年 1 月 30 日
Hi stephan, the problem with your answer is what John said.
Because your using only one equation to solve for t1 when you need e1 and e3 to solve,
the division of e3 by e1 and than taking the inverse of tan t1 is the solution,
this problem is from a test of robotics and im trying to make a matlab function that solvs it,
the hard problem is the multiple solutions and the simplification of the equations, thats why matlab doesn't solve's it, matlab doesn't know it need to do the division and inverse, i still don't know how to solve it. thanks anyway.
Stephan
Stephan 2019 年 1 月 30 日
編集済み: Stephan 2019 年 1 月 30 日
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.

サインインしてコメントする。

質問済み:

2019 年 1 月 30 日

編集済み:

2019 年 1 月 30 日

Community Treasure Hunt

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

Start Hunting!

Translated by