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:
1 次查看(过去 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 个评论
回答(1 个)
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])
hblock = subs(sol.theta1,theta2,theta3)
hblock_sub = double(hblock_sub)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Symbolic Math Toolbox 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!