필터 지우기
필터 지우기

I am looking to solve for the three theta's using sys in an array. How should my code look to make this happen. Heres what I have:

조회 수: 3 (최근 30일)
syms theta1 theta2 theta3
eq1 = theta1 == 90-asin((L1-hblock_sub-h_ram-L3*sin(theta2)-L4*sin(theta3))/L5);
eq2 = theta2 == acos(-(L6-L4*cos(theta3)-L5*cos(90-theta1))/L3);
eq3 = theta3 == acos((L6+L3*cos(theta2)-L5*cos(90-theta1))/L4);
sol = solve([eq1 eq2 eq3],[theta1 theta2 theta3]);
hblock = subs(sol.theta1,theta2,theta3);hblock_sub = double(hblock_sub);
  댓글 수: 1
Torsten
Torsten 2023년 3월 10일
편집: Torsten 2023년 3월 10일
Replace 90 by pi/2.
I don't think this will solve your problem, but it's an error in your equations.
Even better:
Use sin(pi/2-x) = cos(x) and cos(pi/2-x) = sin(x).

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

답변 (1개)

Shushant
Shushant 2023년 3월 13일
From my understanding of your issue, you are trying to solve a set of equations but instead of declaring "theta1", "theta2" and "theta3" separately you want to declare them as part of an array. To accomplish this, you can look through this documentation here. I have tried to implement the same using some random values below.
syms theta [1 3]
L1 = 1;
L2 = 2;
L3 = 3;
L4 = 4;
L5 = 5;
L6 = 6;
hblock_sub = 1;
h_ram = 1;
eq1 = theta1 == 90-asin((L1-hblock_sub-h_ram-L3*sin(theta2)-L4*sin(theta3))/L5);
eq2 = theta2 == acos(-(L6-L4*cos(theta3)-L5*cos(90-theta1))/L3);
eq3 = theta3 == acos((L6+L3*cos(theta2)-L5*cos(90-theta1))/L4);
sol = solve([eq1 eq2 eq3],[theta1 theta2 theta3])
Warning: Unable to solve symbolically. Returning a numeric solution using vpasolve.
sol = struct with fields:
theta1: 91.09127337359374229308322484689 + 0.014498593097431429385469218902618i theta2: 1.4767379109122526840455134003504 + 0.022557641373024566759457348260003i theta3: 0.11249516403464522396375288111294 + 0.0068154950806834305011949243139886i
hblock = subs(sol.theta1,theta2,theta3)
hblock = 
hblock_sub = double(hblock_sub)
hblock_sub = 1

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by