MATLAB Assignment #3

advertisement
MATLAB EXERCISE3
MATLAB Assignment #3
1. Write a MATLAB program to find the first N Fibonacci numbers. ( Fibonacci numbers are 1, 1,
2, 3, 5, 8, …; and the next number in the series is the sum of the previous two.) Remember the first
two are each 1. The user will enter N. Output N and then all N Fibonacci numbers in a row. The
user may test no more than 5 times, and N must be greater than 2. Save this M-file as
userid_dateA (e.g. dfjackson_112906A)
2. Modify the second program from the previous assignment. Calculate the 3 angles in a triangle
after prompting the user to enter the three sides. Previously, you were not required to check to
make sure that the sides were valid. A triangle with sides A, B, and C is valid if all of the following
conditions are true:
A>0
B>0
C>0
A<B+C
B<A+C
C<A+B
Rewrite your MATLAB program from #1 of the last exercise that it will test for valid inputs. The
program should either print out an error message that the inputs are not valid or else print out the
values of the three angles in degrees. Run the program 7 times, including 6 cases where the triangle
is not valid (corresponding to the 6 cases above) and 1 case where the triangle is valid. Turn in a
printout of the program and a printout showing the 6 test cases.
Include plenty of comments in your program. Save this M-file as userid_dateB (e.g.
dfjackson_112906B)
Download