me351_lec04

5f rad or 101f degn theta1 180theta1pi fprintftheta4

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: (th2)+r3cos(th3)+r4cos(th4)-r1cos(th1)=0 % r2sin(th2)+r3sin(th3)+r4sin(th4)-r1sin(th1)=0 % ang=(pi/180)*ang; [theta, fail]=position(lnk, ang); if fail error(’Newton method fails’); end fprintf(’theta3= %10.5f rad, or %10.1f deg\n’, theta(1), 180*theta(1)/pi); fprintf(’theta4= %10.5f rad, or %10.1f deg\n’, theta(2), 180*theta(2)/pi); % % Now compute the influence coefficients. These satisfy: % % -r3sin(th3)k3-r4sin(th4)k4= r2sin(th2) % r3cos(th3)k3+r4cos(th4)k4=-r2cos(th2) % or % J(th3,th4)[k3;k4]=[r2sin(th2);-r3cos(th2)] % where J is the Jacobian matrix % coef=velocity(lnk, [ang(1); ang(2); theta]); 2 fprintf(’omega3= %10.5f rad/sec\n’, coef(1)*omega2); fprintf(’omega4= %10.5f rad/sec\n’, coef(2)*omega2); %================================================== function [theta, fail]=position(lnk, ang, maxit, err) % % Position analysis for a four bar linkage via Newton’s % method. Calls functions ‘loop’ and ‘Jacob’ to compute % the loop equations and Jacobian determinant. % fail=0; if nargin<2 error(’Not enough arguments’); elseif nargin==2 maxit=10; err=sqrt(eps); elseif nargin==3 err=sqrt(eps); end delta=loop(lnk, ang); th3=ang(3); th4=ang(4); theta=[th3; th4]; if norm(delta,1) <= err return; end k=1; % set iteration counter while k<=maxit & norm(delta,1) >= err Jmat=Jacob(lnk, th3, th4); cor=-Jmat\delta; th3=th3+cor(1); th4=th4+cor(2); % Newton’s method used to find improved values ang(3)=th3; ang(4)=th4; delta=loop(lnk, ang)...
View Full Document

This document was uploaded on 11/08/2013.

Ask a homework question - tutors are online