CS 221 PRACTICE Lab Quiz 1 2011

Part 1: Excel Fundamentals

In manufacturing metal components, pieces are hardened by heating them to extreme temperatures and then cooling or "quenching" them in an oil bath. The temperature of the part is a function of the time it has been submerged in the oil bath. The equation for T(t), the temperature at time t, is as follows:
T(t) = (Ti - Tb)e-t/τ + Tb
where Ti is the initial temperature of the part, Tb is the temperature of the bath, and τ is a time constant that accounts for properties of the oil bath, the shape of the part, etc. Create a spreadsheet that shows the temperature of a certain part over time, at fixed intervals of time, according to the above equation. Use the following values for parameters:
Ti = 800 C
Tb = 200 C
τ = 50 sec
Time step = 0.1 sec

Your spreadsheet should have the following characteristics (10 points each):

Using different values for the constants, this is how the spreadsheet should look:

Ti (° C): 400
Tb (° C): 100
τ (sec): 10
time step (sec):   0.5
   
Time Temperature
0.0 400.0
0.5 385.4
1.0 371.5
1.5 358.2
2.0 345.6
2.5 333.6
3.0 322.2
...

Hint: The built-in function EXP(x) computes ex, where e is the base of the natural logarithm.


Part 2: MATLAB Fundamentals

Write a script to compute the length (c) of the hypoteneuse of a right triangle, given the lengths (a and b) of its two sides. Recall that this length satisfies the equation:

c² = a² + b²
Of course, to find the value of c given a and b, you will need to take the square root of both sides. Recall that you can use the built-in function sqrt() in MATLAB to compute a square root.

Your script must have the following characteristics (worth 10 points each):

Here is an example of how the program should behave:
>> hypot
>> Please enter the length of side a: 3
>> Please enter the length of side b: 4
>> c =

       5.0000
>>