Help solving system of triq equations
Show older comments
I am using matlab to create a script to solve for the angles theta 3 and theta 4 with an input of theta 1 and theta 2 of a fourbar
theta 1 is set to 0 for this data set however next time i call this function it will not be zero and will refrence the output from the first iteration
%Input Linkage lengths
d=11.875;
a=2.5;
b=11.875;
c=3.75;
r5=5;
r6=6;
r7=7;
r8=8;
L1Theta = zeros(30,4);
L1Theta(:,2) = [linspace(0,2*pi,length(L1Theta))];
positionsolver(a,b,c,d,L1Theta(:,1),L1Theta(:,2),length(L1Theta))
function [theta3,theta4] = positionsolver(A,B,C,D,theta1,theta2,L)
for n = 1:L
Theta1 = theta1(n)
Theta2 = theta2(n)
syms Theta1 Theta2 A B C D Theta3 Theta4
eq1 = (A*cos(Theta2(n)) + B*cos(Theta3) - C*cos(Theta4) - D*cos(Theta1(n))) == 0
eq2 = (A*sin(Theta2(n)) + B*sin(Theta3) - C*sin(Theta4) - D*sin(Theta1(n))) == 0
vars = [Theta3,Theta4]
sol = solve([eq1,eq2],vars)
theta3(n) = simplify(sol.Theta3)
theta4(n) = simplify(sol.Theta4)
end
end
end
Accepted Answer
More Answers (0)
Categories
Find more on Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!