# Matlab

There are three parts to this assignment: 1. There is a video for you to watch, and then a small activity. Videos: Activity (from Mathworks): You are asked to complete Exercise 1 as practice, and then complete exercise 2 for this assignment. You will turn in a word document with your work copy and pasted into the word document. At its heart, MATLAB is a big calculator. To calculate something simply type it in at the command prompt and press Enter . Thus, to calculate 1 + 1 we type it in and press Enter . The screen should show: >> 1+1 ans = 2 meaning that the answer is 2. Exercise 1. Run MATLAB, find the command window and the blinking cursor. Find the answer to the following arithmetic problems: ? 1234+4321=? ? 104-765=? ? 47*33=? ? 344=? (The operator for power is the circumflex ^, usually found by pressing Shift ? 6 ? How far is 192 from its approximation 2022 2 * 20 (Remember that (a-b)2=a2-2ab+b2, thus the answer should be 1) ? Find an approximation to 1/73 ? Find an approximation to v31 (while you can of course use the fact that vx = x0.5 , you can also look for a dedicated function square root by learning how to use the lookfor command.) ? If you get 5% interest-rate (yearly) on a loan, compounded monthly, and you start with $1000, how much money will you have after 20 years? (dont be confused by an answer of the form 2.7e3 which simply means 2.7103) ? If two sides of a right triangle have lengths 31 and 45, what is the length of the hypotenuse? ( You should get 54.6) You may have noticed in the exercises that the answer is only given with 5 digits of accuracy (at most). For example, we can ask MATLAB for the value of p and get: >> pi ans = 3.1416 Internally, MATLAB keeps a 16 (more-or-less) digit version of the number it shows us, but to keep things orderly, it only displays the answer rounded to show 5 digits (by default). We can change this by issuing a command: >> format long >> pi ans = 3.141592653589793We can see this, by subtracting part of p from and, which always holds the full, unrounded answer to the previous, unassigned expression: >> format short >> pi ans = 3.1416 >> ans-3.1415 ans = 9.2654e-05 >> ans 9.2653e-5 ans = 5.8979e-10 Exercise 2. Remember the cosine rule? C2=a2+b2-2abcos(?). Find the length of the hypotenuse of a triangle with angle 30?, and sides with lengths 10 and 20. The MATLAB trigonometric functions (cos, sin, tan) use radians, so you will need to convert using p. For guided practice and further exploration of how to use the command prompt c is your hypotenuse, and the sides are a and b. Please copy and paste your answer in word and send in via canvas.