Summer II 2021 MATH 9 Midterm I Aug 16, 2021 You have 24 hours to take this 50 points midterm. Books and notes are allowed. You can not use internet while you are taking your midterm. Create a MATLAB script in an m-file and then executing the file. Name this file MidtermI YourName.m. All commands should be followed by a semi-colon ; so that when the script is run, no mid-step gets displayed to the screen. To receive full credit, you must use exact variables names given below, and you must not have any terms getting printed to the screen. The screen only shows the final answer for each problem.
1. (10 points) Write a user-defined MATLAB function (name this function myfunction YourName) for the following math function:
y(x) = 0.6x3e?0.47x + 1.5x2e?0.6x
The input to the function is x and the output is y. Write the function such that x can be a vector (use element-by-element operations).
(a) Use the function to calculate y(?2), y(0) and y(4). (b) Use the function to make a plot of the function y(x) for ?5 ? x ? 8 with a blue dotted
line. (c) Marker the point(s) y(x) = 0 with green * and text label their coordinates. Add a title
and label the axes.
2. (10 points) The value of ? can be estimated from the expression:
2
? =
? 2
2 · ?
2 + ?
2
2 ·
? 2 +
? 2 + ?
2
2 · · · ·
Write a MATLAB program in a script file that determine ? for any number of terms. The program asks the user to enter the number of terms, and then calculates the corresponding value of ?. Execute the program with 5, 10, and 40 terms. Compare the result with pi. (Use format long.)
3. (10 points) Fibonacci numbers are the numbers in a sequence in which the first two elements are 0 and 1, and the value of each subsequent element is the sum of the previous two elements:
0, 1, 1, 2, 3, 5, 8, 13, · · ·
Write a MATLAB program in a script file that determines and displays the first 20 Fibonacci numbers. Do NOT use MATLABs built-in function fibonacci.
4. (10 points) Write a MATLAB program in a script file that finds and displays all the numbers between 100 and 999 whose product of digits is 6 times the sum of the digits. [e.g. 347 since 3×4×7 = 6(3+4+7)]. Use a for-end loop in the program. The loop should start from 100 and end at 999.
5. (10 points) (a) What are the most appropriate MATLAB script to output the following sequences? Please
show the first 10 terms. You should show all 6 terms of …. [Hint: the answer is NOT unique! You only need to show one answer of the rest 6 terms.]
? 1
3 ,
1
6 ,?
1
9 ,
1
18 , …
(b) How are you doing so far? What is the most challenging part for you in MATH 9? How can the instructor help you succeed in MATH 9?
You have to upload two m-file(s) (MidtermI YourName.m and/or myfunction YourName.m) on Grade- scope by the end day of Aug 16, 2021.
Recent Comments