grashof函數第一式
程式4.1之呼叫函數為grashof():
function ans=grashof(ground_no,linkage)
其參數定義如下:
ground: 接地桿在linkage中之桿序。
Linkage: 列矩陣,四連桿長度,其次序不拘。
程式4.1
function ans=grashof(ground_no,linkage)
% Function to test the Grashof linkage
% Inputs:
% ground_no:the ground link number in the order
% linkage: row matrix for lengths of the 4 links
% in original assigned order.
% Example:ans=grashof(4,[4 4.2 2.6 2])
% Revised: March 4, 2006
ground=linkage(ground_no);
link=sort(linkage);% sorting the links
ig=find(linkage==link(1));
if link(1)+link(4)>link(3)+link(2),
ans='Non-Grashof Linkage';
elseif link(1)+link(4)==link(3)+link(2)
ans='Neutral Linkage';
elseif link(1)==ground,
ans='Double-Crank Linkage';
else
switch ig
case 1
im=3;
case 2
im=4;
case 3
im=1;
case 4
im=2;
end
if ground==linkage(im)
ans='Double-Rocker Linkage';
else
ans='Crank-Rocker Linkage';
end
end
範例4.1:四連桿組之長度如下:
L1 | L2 | L3 | L4 | 接地桿號 | |
---|---|---|---|---|---|
a | 2 | 4.5 | 7 | 8 | 1 |
b | 3 | 5 | 4 | 4 | 2 |
c | 3.5 | 4 | 1 | 5 | 2 |
d | 4 | 5 | 3 | 7 | 2 |
(a) s=2, g=8, p=4.5,q=7
s+g=10<p+q=11.5
故應為葛拉索一型,至少有一桿為曲柄桿,其接地桿為最短桿s,故應為雙曲柄機構。用程式計算得知答案如下:
>> ans=grashof(1,[2 4.5 7 8])
ans =Double-Crank Linkage
(b) s=3, g=5, p=4,q=4
s+g=8 = p+q=8
因為相等,故屬於中立連桿組。用程式計算得知答案如下:
>> ans=grashof(2,[3 5 4 4])
ans =Neutral Linkage
(c) s=1, g=5, p=4,q=4
s+g=6<p+q=8
故應為葛拉索一型,至少有一桿為曲柄桿,其接地桿為第二桿,為最短桿s之側桿,故應為曲柄搖桿機構。用程式計算得知答案如下:
>> ans=grashof(2,[3.5 4 1 5])
ans =Crank-Rocker Linkage
(d) s=3, g=7, p=4,q=5
s+g=10>p+q=9
為非葛拉索型,無論任何桿接地均屬雙搖桿機構。用程式計算得知答案如下:
>> ans=grashof(2,[4 5 3 7])
ans =Non-Grashof Linkage
grashof2函數第二式
本程式係就原grashof函數修正而得。其輸入僅有四支連桿之長度,其第一桿為接地桿,其餘依序為第二、三、四桿。其輸出內容不立即印出,可由參數ans及代碼b作輸出,作為後繼程式呼叫之用途。
function [ans,b]=grashof2(linkage)
% revised from ans=grashof(groundno,linkage)
% Function to test types of Grashof linkages
% in which the first link is ground
% linkage: lengths of 4 links, in row matrix
% b: code(0-6),representing types of answers
% Example:[ans,b]=grashof2([4 4 5 6])
% Author: D S Fon, Bime, NTU, Oct. 25, 2007
link=sort(linkage);
ig=find(linkage==link(1));% find the shortest
if link(4)>=link(3)+link(2)+link(1)|length(linkage)~=4,
b=0;ans='Inputs fail to describe a 4-bar linkage!';
return;
end
if link(1)+link(4)>link(3)+link(2),
b=7;ans='Non-Grashof triple-rocker linkage';
return;
end
if link(1)+link(4)==link(3)+link(2)
if linkage(1)==linkage(2)&linkage(3)==linkage(4),
b=2;ans='Natural diamond double-crank linkage.';
elseif linkage(1)==linkage(3)&linkage(2)==linkage(4),
b=3;ans='Natural parrellel double-crank linkage.';
else
b=4;ans='General Natural linkage.';
end
return;
end
if link(1)==linkage(1),
b=1;ans='Double-Crank linkage with rotating coupler.';
elseif link(1)==linkage(3)
b=5;ans='Double-Rocker linkage with rotating coupler.';
else
b=6;ans='Crank-Rocker linkage with rotating crank.';
end
end
執行例
依據前述使用grashof函數之例子,重新執行如下:
>> [ans,b]=grashof2([2 4.5 7 8])
ans =
Double-Crank linkage with rotating coupler.
b =
1
>> [ans,b]=grashof([3 5 4 4])
??? Undefined command/function 'grashof'.
>> [ans,b]=grashof2([3 5 4 4])
ans =
General Natural linkage.
b =
4
>> [ans,b]=grashof2([3.5 4 1 5])
ans =
Double-Rocker linkage with rotating coupler.
b =
5
>> [ans,b]=grashof2([4 5 3 7])
ans =
Non-Grashof triple-rocker linkage
b =
7
>> [ans,b]=grashof2([4 4 5 6])
ans =
Non-Grashof triple-rocker linkage
b =
7
No comments:
Post a Comment