Trouble Coding Kinematics Problem

조회 수: 3 (최근 30일)
Bailey Smith
Bailey Smith 2018년 10월 9일
답변: Sebastian Castro 2018년 10월 9일
I am trying to code this problem into MATLAB. I want to solve for theta3, theta4, w3, and w4 (w being omega). I am having some trouble getting my thetas to work. When I try to solve, say, for theta2=95 degrees, I keep getting 0 and 1 degree, respectively. Is my problem just setting up the code incorrectly, or is it something else?
Thank you in advance!
clear; clc;
theta2=input('Enter a Value For Theta 2 in Degrees: ');
w2=10;
OC=10;
OA=4;
AB=12;
BC=7;
w1=0; %ground; can't move
theta1=0; %ground; no angle
syms theta3 theta4
%R2+R3=R1+R4 -> OA+AB=OC+BC -> OA+AB-OC-BC=0
eq1=OA*cos(theta2)+AB*cos(theta3)-BC*cos(theta4)-OC*cos(theta1)==0;
eq2=OA*sin(theta2)+AB*sin(theta3)-BC*sin(theta4)-OC*sin(theta1)==0;
sol1=solve([eq1,eq2], [theta3 theta4]);
theta3_=sol1.theta3;
theta4_=sol1.theta4;
% syms w3 w4
%
% %time derivative equations = velocity equations
% eq3=-(OA*sin(theta2)*(w2))-(AB*sin(theta3)*w3)+(BC*sin(theta4)*w4)==0;
% eq4=(OA*cos(theta2)*(w2))+(AB*cos(theta3)*w3)-(BC*cos(theta4)*w4)==0;
fprintf('Theta 3 is %.f degrees\n',theta3_(1))
fprintf('Theta 4 is %.f degrees\n',theta4_(1))
% fprintf('The angular velocity of omega 3 is %.f rad/s\n',w3)
% fprintf('The angular velocity of omega 4 is %.f rad/s\n',w4)

채택된 답변

Sebastian Castro
Sebastian Castro 2018년 10월 9일
You probably want to convert from degrees to radians, since the sin and cos functions accept radians.
That, or you can use sind and cosd instead.
- Sebastian

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by