Quiz 1 - Go!!

NOTE

You can use either desktop or command-line Matlab to complete the quiz, whichever you prefer.

Remember that all of your commands have to entered (ultimately if not immediately) in the script file

/phys210/$LOGNAME/matlab/q1.m

Note the following:

  1. Angular measure is in radians unless otherwise specficied.

  2. Don't worry if the numbers in your output have trailing zeros that don't appear in the problem description: e.g

    2.0000
    

    rather than

    2
    

Q1.1

Calculate \[ 23\left( -8 + \frac{\sqrt{607}}{3}\right) + \left( \frac{40}{8} + 4.7^2\right)^2 \] assigning the value to the variable q11

Q1.2

\[ \cos\left(\frac{5\pi}{6} \right) \sin^2\left(\frac{7\pi}{8} \right) + \frac{\tan\left(\frac{\pi}{6}\ln8\right)}{\sqrt{7} + 2} \] assigning the value to the variable q12

Q1.3

Define the variables \(x\) and \(z\) as \(x=5.3\), and \(z=7.8\), then evaluate: \[ \frac{xz}{\left( x/z\right)^2} + 14 x^2 - 0.8 z^2 \] assigning the value to the variable q13

Q1.4

The distance \(d\) from a point \( (x_0, y_0) \) to a line \( Ax + By + C = 0 = 1\) is given by \[ d = \frac{\lvert Ax_0 + By_0 + C\rvert}{\sqrt{A^2 + B^2}} \] Determine the distance of the point \((-3,4)\) from the line \(2x - 7y - 10 = 0\). First define the variables \(A\), \(B\), \(C\), \(x_0\) and \(y_0\), and then calculate \(d\), i.e. assign to the variable d.

Q1.5

Create a row vector named vr_q15 that has the elements \(6\), \(8\cdot3\), \(81\), \(e^{2.5}\), \(\sqrt{65}\), \(\sin(\pi/3)\) and \(23.05\)

Q1.6

Create a column vector named vc_q16 that has the elements \(44\), \(9\), \(\ln(51)\), \(2^3\), \(0.1\) and \(5\tan(25^\circ)\).

Q1.7

Use the colon operator to create the row vector \[ W = \left[ \begin{array}{cccccccc} 3.1 & 4.1 & 5.1 & 6.1 & 7.1 & 8.1 & 9.1 & 10.1 \end{array} \right] \] (assign to the variable W.)

Q1.8

Use the linspace command and the transpose operator (I won't tell you what that is here) to create the column vector \[ Z = \left[ \begin{array}{c} -1.0\\ -0.5 \\ 0.0 \\ 0.5 \\ 1.0 \\ 1.5 \\ 2.0 \\ 2.5 \end{array} \right] \] Assign to the variable Z.

Q1.9

Create the matrix shown below by using the vector (colon) notation for creating vectors with constant spacing and/or the linspace command when entering the rows. \[ R = \left[ \begin{array} {cccccccc} 0 & 4 & 8 & 12 & 16 & 20 & 24 & 28\\ 69 & 68 & 67 & 66 & 65 & 64 & 63 & 62\\ 1.4 & 1.1 & 0.8 & 0.5 & 0.2 & -0.1 & -0.4 & -0.7 \end{array} \right] \] Assign to the variable R.

Q1.10

Create the row vector \[ V = \left[ \begin{array}{cccccccc} 3.1 & 4.1 & 5.9 & 2.6 & 5.3 & 5.8 & 9.7 & 9.3 \end{array} \right] \] Assign to the variable V.

Then, with a single MATLAB command that uses one of the built-in math functions, create a vector containing the result of rounding each element of \(V\) to the nearest integer. Assign the result to V_round

Q1.11

With a single MATLAB command that uses one of the built-in math functions, create a vector whose elements are those of \(V\) (as defined above) with the fractional parts discarded (e.g. 2.0001 and 2.9999 would both become 2). Assign the result to V_int

Finishing up

IMPORTANT

When you've completed the quiz, execute the following from the terminal command line:

% date > /phys210/$LOGNAME/matlab/date

YOU CAN THEN WORK ON THE HOMEWORK OR TALK TO ME ABOUT YOUR TERM PROJECTS WHILE YOU WAIT FOR THE CLASS TO FINISH THE QUIZ