Practice Test

Click here for data and code files necessary to complete the practice problems.

The provided text file (readings.txt) contains a timestamp broken up into year, month, day, hour, minute, second, and timezone components, as well as a reading from a sensor. Write a script that reads the data from the file using the textscan function.

The script must:

Convert the timestamps into single numeric serial date numbers stored in a variable named dates

Ignore the timezone component of the timestamp by not reading it into the workspace

Place numeric values for the readings in a single array of type double with a variable name of readings

The provided data file (viewdata.mat) contains a 19-by-3 matrix viewdata with the following columns:

Video Length - Length in minutes for the video

Views - Number of times the video has been viewed

Minutes Watched - Total amount of time viewers spent watching the video

Write a MATLAB script to analyze the data to determine the effect of video length on viewer retention with the following steps:

The x-coordinates of the weather station locations (in km) stored in the column vector x

The y-coordinates of the weather station locations (in km) stored in the column vector y

The temperature data corresponding to the station locations (in degrees C) stored in the column vector T

Write a MATLAB script to load the data from the file and produce a contour plot similar to the one below with the temperature stations. Use the griddata function with 'v4' as the interpolation method to estimate the temperatures for the x-y spatial grid points.

Create an anonymous function f which accepts a (possibly vector valued) numeric input and returns a (possibly vector valued) numeric output according to the mathematical formula f(x) = x^2 - sin(x). Use this function along with the fminsearch function to find the local minimum value near the initial value near x0 = 0.5. Store the local minimizing value and the corresponding function value in the variables xmin and ymin respectively.

A function called viewImage accepts an image and a variable number of parameter name/value pairs as shown in the function heading:

function viewImage (I, varargin)

Write the validation code in the body of the function to produce an error message explaining the violation if any of the following conditions on the input arguments are not met:

If variable input options exist, they must exist in pairs

The names portion of the variable input must occur before the corresponding value. Names must be strings of the value 'zoom', 'rotate', or 'tilt'

The value portion for a variable input must be numeric

Do not write any implementation beyond the code required to perform the validation.

The provided script (diceSimulation.m) runs a simulation of rolling six, 6-sided dice and calculating the sum. The simulation is repeated 1,000,000 times to create a histogram of the probability distribution as shown below.

The code produces the correct result, but can be improved to run faster. Rewrite the script such that the simulation produces the same results with 1,000,000 trials, a histogram of the results is created, and a faster execution time.

The figure illustrates on result from running the script. Solutions should have a similar distribution.

The provided script (LoadData.m) loads data from an impact simulation, and uses the plotyy function to plot position on the left y-axis and velocity on the right y-axis. Using the outputs from the plotyy function, modify the figure to make it look as shown in the figure below.

The figure must contain:

an x-axis with a minimum value of 0 and a maximum value of 4

a plot of the position vector as a solid blue line

a left y-axis colored in blue with a minimum value of -5 and a maximum value of 5

a plot of the velocity vector as a dashed black line

a right y-axis colored in black with a minimum value of -0.5 and a maximum value of +0.5

a right y-axis colored in black with a minimum value of -0.5 and a maximum value of +0.5

a title reading "Impact Data" as shown in the figure

a legend in the top center of the axes with the correct label for each plot

The provided graphical application (see screenshot below) plots a sine wave based on the provided amplitude and frequency using the equation y = amplitude*sin(2*pi*frequency*x) on the interval defined by [0 2*pi].

Write the callback functions for the slider controls to update the plot. The callbacks must:

Update the plot with the new amplitude or frequency

Update the display of the amplitude and frequency values (tag names edtAmplitude and edtFrequency respectively.

Additionally, display a plot with the default values for amplitude and frequency upon starting the application.

Select a Web Site

Choose a web site to get translated content where available and see local events and
offers. Based on
your location, we recommend that you select: .

This website uses cookies to improve your user experience, personalize content and ads, and analyze website traffic. By continuing to use this website, you consent to our use of cookies. Please see our Privacy Policy to learn more about cookies and how to change your settings.