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
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
2019년 1월 30일
답변 (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
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)))
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
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.
카테고리
도움말 센터 및 File Exchange에서 Special Values에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!