CS1321 - Lab 4 - Check Your Answers

Problem 1: lab4_script.m

For the first part, simply type in a and b at the command prompt and see that the output matches that shown in the lab. Then type c at the command prompt and see that it includes all of the numbers 1 to 42.

For the next bit, compare the graph you see to this one: [Graph A]

For the second part, compare your graph to this one: [Graph B]



Problem 2: fact.m & Problem 3: fibonacci.m

Compare your answers to this sample data:

>> fact(0) % should return 1
>> fact(1) % should return 1
>> fact(5) % should return 120
>> fact(50) % should return 3.0414e+64

>> fibonacci(0) % should return 0
>> fibonacci(1) % should return 1
>> fibonacci(5) % should return 5
>> fibonacci(6) % should return 8
>> fibonacci(7) % should return 13


Also, make your own data and check your function thoroughly.



Problem 4: rotation.m

Make a few tests to see if it will perform a rotation, like this:

>> [1 0] * rotation(pi/4) % should return [0.7071 -0.7071]
>> [1 0] * rotation(0) % should return [1 0]
>> [7 5] * rotation(2.19) % should return [0.0090 -8.6023]


You can also look just at the matrix produced by a particular rotation and see if it looks right.


Last modified: Tue Oct 30 21:31:19 EST 2001