function run for i=1:100 r(i)=15; end for i=101:201 r(i)=15+(5/100)*(i-100);%畫出半徑長 end for i=201:260 r(i)=20; end for i=261:360 r(i)=20-(5/100)*(i-260);%畫出半徑長 end theta=linspace(0,2*pi,360); for i=1:360 k=r(1); for j=1:359 r(j)=r(j+1);%元素取代 end r(360)=k; polar(theta,r);%用及坐標繪出圖形 pause(0.00001) end
若以M為固定點,做逆時針旋轉,假設為等假角速度ω,則Vp=(ω) x (r),若以複數座標表示iωr*exp(iωt+iθ),而向心加速度為-(ω^2) x (r)以複數座標表示為-ω*ω*r*exp(iωt+iθ)。若從Q點看P點的速度為Vp=Vq +(ω) x (r)。若在M點有一水平速度,則P點速度為Vp=Vo + (ω) x (r) 若以複數座標表示v+iωr*exp(iωt+iθ)。若在M點同時有水平加速度,則P點速度為Vp=Vo+at+v+(ω) x (r)若以複數座標表示為v+at+iωX*exp(iωt+iθ),加速度為a=a-(ω^2) x (r),以複數座標形式為a-ω*ω*Xexp(iωt+iθ)。如果速度和加速度不為水平的,則只要分成水平方向和垂直方向。
function [s,theta21,theta22]=slider_limit(R,L,e) % P4.7 [s,th1,th2]=slider_limit(r) % % Find the stroke, extreme angles of link 2 in a slider mechanism system % Input:R,L lengths of crank & connecting rod; e the offset of block % Output: s:stroke, theta21:angle for the right position, % theta22:angle for the left position % Examples: % [s,th1,th2]=slider_limit(5,12,3) % % Designed by D.S. Fon, BIME, NTU, Date:October 17,2002. d2g=pi/180; th1=asin(e./(R+L)); th2=asin(e./abs(R-L)); s=(R+L).*cos(th1)-abs(R-L).*cos(th2); theta21=th1/d2g; theta22=th2/d2g;
function [d,theta3]=slider_solve(theta2,R,L,e,mode) % P4.8 [d,theta3]=slider_solve(theta2,R,L,e) % % Find the block coordinate and angle of connecting rod in a slider-crank system % Input:R,L lengths of crank & connecting rod; e the offset of block % theta2: angles of crank, cane be a matrix % Output: d:distance of the block from the origin. % theta3:angle of the connecting rod, % Examples: % [d,theta3]=slider_solve(45,5,10,3) % % Designed by D.S. Fon, BIME, NTU, Date:Fegruary 9,2003. if nargin<5, mode="0;end" d2g="pi/180;" theta="theta2*d2g;" cc="(e-R.*sin(theta))./L;">=0, theta3=asin(cc); else theta3=asin(-cc)+pi; end d=L.*cos(theta3)+R.*cos(theta); theta3=theta3./d2g;
上面程式為機動學光碟裡程式,運用上面程式再配合下面所寫程式即可畫出連桿
function slider_draw1(R,L,e) %R為曲桿 L為聯結桿 e為偏至距離 %example:slider_draw1(17,23,10) [s,theta21,theta22]=slider_limit(R,L,e) thea2=asind((L-e)/R)+180; ang=linspace(theta21,thea2,100);%分成100個點 [d,theta3]=slider_solve(ang,R,L,e,1) x=R*cosd(ang); y=R*sind(ang); for n=1:100 link_plot([0,x(n),d(n)],[0,y(n),e],2);%此為之前程式 line([d(n)-3,d(n)+3,d(n)+3,d(n)-3,d(n)-3],[e-2,e-2,e+2,e+2,e-2]);%畫出滑塊 axis equal axis ([-45 45 -30 30]); pause(0.01) clf end thea3=asind((L-e)/R); ang=linspace(thea2,-thea3,100); [d,theta3]=slider_solve(ang,R,L,e,-1) x=R*cosd(ang); y=R*sind(ang); for n=1:100 link_plot([0,x(n),d(n)],[0,y(n),e],2); line([d(n)-3,d(n)+3,d(n)+3,d(n)-3,d(n)-3],[e-2,e-2,e+2,e+2,e-2]); axis equal axis ([-45 45 -30 30]); pause(0.01); clf end thea3=asind((L-e)/R); ang=linspace(-thea3,theta21,100); [d,theta3]=slider_solve(ang,R,L,e,1) x=R*cosd(ang); y=R*sind(ang); for n=1:100 link_plot([0,x(n),d(n)],[0,y(n),e],2); line([d(n)-3,d(n)+3,d(n)+3,d(n)-3,d(n)-3],[e-2,e-2,e+2,e+2,e-2]); axis equal axis ([-45 45 -30 30]); pause(0.01); clf end