Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

CSE 317 Numerical Methods [SET A] Time: 30 minutes

Summer 2019 Points: 15

LAB EXAM 1

Name:

ID:

Answer the following questions.

1. Do a scatter plot of two vectors. Both vectors should be randomly generated and have size of 20. Add the following title to your
plot “scatter plot of random vectors”.

2. Write a MATLAB function that takes as input two vectors x and y, and returns rms(demean(x)), rms(demean(y)), and
cosine_distance(x,y), if the vectors are of the same dimension, otherwise displays the error message “dimension mismatch”.

3. Write a MATLAB function that inputs a vector x and a number n, and produces the matrix with n rows each containing vector x.
(you cannot use repmat()).
CSE 317 Numerical Methods [SET B] Time: 30 minutes

Summer 2018 Points: 15

LAB EXAM 1

Name:

ID:

Answer the following questions.

1. Write down MATLAB code to plot the following function:

f ( x )=−log ( xT β ) , x=[ 1 4 ] , β is a 2−vector ¿ [ −3 ,−3 ] ¿ [ 3 ,3 ] with stepsize 0.1

2. Write a MATLAB function that takes two vectors x and y and returns the projection of x on y and projection of y on x if x and y are
of the same length, otherwise returns “dimension mismatch”.

3. Write a MATLAB function that finds all indices of odd numbers between 1 and 10.

You might also like