星期六, 9月 30, 2006

MATLAB課堂作業: 作業一

1. The unit of POWER can be expressed as W, kW, hp, etc. Their equivalent expressions are J/s, kJ/s, in which J is joule to represent work and 1 J=0.101972kgm (You may find unit conversion table at http://www.digitaldutch.com/unitconverter/). Now, by using such relations find out the following condition when a farm tractor pulls a farm equipment working on the field at 20m/min. Suppose the draft force is meaured as 200kgf. Find out the power of the tractor.
(試利用上述的關係,計算下面的情況:設若一台曳引機(Tractor)拉引某一農具,其拉力測得200公斤,試計算此需要多少功率(動力、馬力或kW)才能該農具在一分鐘內拉動20m?)


ANS:
>> % Question 1
>> % To find out the power of the tractor
>> f=200; % 曳引機(tractor)拉力f為200公斤
>> d=20; % 向前拉動20m
>> J=0.101972; % 單位換算1 J=0.101972kgm
>> t=60; % 需時60秒
>> p=f*d/J/t % 功率p=f*d/J/t

p =

653.7742

>> % 執行結果:所需之功率為653.7742瓦特

2. A circuit with three resistors rated 1, 20,200 ohms in series is connected to a voltage source of 110V. Find the line current and power consumption.
(有一電路,以1、20及200歐姆之電阻器相串聯,試計算當此電路兩端加於110V電源時,其流經之電流及所耗之功率。)


ANS:
>> % Question 2
>> % Find the line current and power consumption
>> r=1+20+200; % 三電阻器串聯後之總電阻r
>> i=110/r; % 110伏特之電源除以總電阻得流經之電流i
>> p=i*110; % 電流與電壓之乘積得消耗功率
>> i

i =

0.4977

>> p

p =

54.7511
>> % 執行結果: 流經之電流為0.4977安培及所耗之功率為54.7511瓦特
>> % 討論: 第一、二題透過已有之物理基礎,了解消耗功率計算之方式,再加以MATLAB語法逐步計算求得解答,並非難事。

3. Calculate the area of a trangle with three sides in 650cm, 428cm, 282cm, repectively.
(一個三角形三邊分別為650、428、282cm,試計算其面積為多少平方公分。)


ANS:
>> % Question 3
>> % To calculate the area of a trangle
>> a=650;
>> b=428;
>> c=282; % 三角形三邊長分別為650、428、282公分
>> r=(a+b+c)/2;
>> area=(r*(r-a)*(r-b)*(r-c))^(1/2) % 以海龍公式計算三角形面積

area =

4.5233e+004

>> % 執行結果: 三角形面積為(4.5233e+004)平方公分

4. A hog house was designed the way that heat dissipations from lighting & equipment 25,000BTU/hr, heat flux through wall & cellings 52,000BTU/hr , heat flux through aerations 84,300BTU/hr. Suppose each hog will dissipate 600BTU/hr, how many hogs this house can raise?
(在一個規模的現代化豬舍中,其照明及設備操作所產生的熱量為25,000BTU;設經過牆壁及屋頂之流出之熱流量每小時為52,000BTU(英熱單位),利用風扇散熱的熱流量每小時為84,300BTU。然而飼養的豬隻中,每隻每小時產生600BTU之熱。試求此豬場要養多少隻豬才是合適的情況?)


ANS:
>> % Quesiotn 4
>> % How many hogs this house can raise?
>> a=52000+84300; % 每小時總散熱量為a
>> h=(a-25000)/600; % 每小時總散熱量a減去照明及設備操作所產生的熱量為所有豬隻能產生的最大熱量
>> % 所有豬隻能產生的最大熱量除以每隻豬每小時產熱後得一數值h
>> floor(h) % 取出小於或等於數值h的最大數目即為合適的豬隻量,以floor(x)指令執行

ans =

185
>> % 執行結果: 豬舍中養185隻豬最合適

5. The flow rate of a rectangular water gate can be calculated from the following formula: Q=3.33x[L-0.2H]^(3/2), in which L: width of gate in ft, H:water head in ft and Q: the flow rate in cu. ft./s. Find the flow rate Q if L=4 ft and the wate head is 0.9 ft.
(一個矩形堰之流量率通常用下列公式計計:Q=3.33x[L-0.2H]^(3/2),其中Q為流量(立方呎/秒);L為堰開口寬度(呎);H為堰口溢流水頭高度(呎)。若堰口寬度為4呎,堰口溢流水頭高度為0.9呎,問其流量每秒為多少立方呎?)


ANS:
>> % Question 5
>> % Find the flow rate Q
>> L=4; % 堰口寬度L為4呎
>> H=0.9; % 堰口溢流水頭高度H為0.9呎
>> Q=3.33*(L-0.2*H)^(3/2) % 流量為Q

Q =

24.8622
>> % 討論: 一剛開始看到已有公式,不加多想變複製至MATLAB視窗中執行,出現error訊息後才驚覺須以MATLAB語法重新闡述方可順利計算求解,程式語法之撰寫實在需要多加謹慎小心