MathLab question

For this lab, you’ll need to download the following file, and place it into your working directory (It should be visible in the File Browser window).

lab4Data-1.mat

1. In 1999, a space probe ignited and broke into pieces around Mars. The two teams who worked on the probe used different units of measurements, causing this catastrophe. Unfortunately, the TNR (Totally Not Real) Mars Rover has a similar mistake. As it is travelling across Mars it is collecting rock samples and taking measurements in Celsius, Meters, and Kilograms. A research team has written all their programs for data analysis in Imperial units: Fahrenheit, Feet, and Pounds. The rover has sent the data as a 50×3 matrix, where each row corresponds to one of 50 rock samples. The first column is the temperature of the samples in Celsius. The second column is the diameter of the samples in Meters. The third column is the mass of the samples in Kilograms. Below are the first three rows.

LaTeX: \begin{bmatrix}
  -90.311   &  0.982  &   0.795\\
     6.504   &  0.796  &   0.535\\
   -20.331  &   0.992 &    0.777\\
 & \vdots
\end{bmatrix}[ − 90.311 0.982 0.795 6.504 0.796 0.535 − 20.331 0.992 0.777 ⋮ ]

The first sample was measured to have a temperature of -90.311° C, a diameter of 0.982 Meters, and a mass of 0.795 Kilograms, corresponding to the row LaTeX: \begin{bmatrix}<p data-verified=-90.311 & 0.982 & 0.795

\end{bmatrix}”>

[ − 90.311 0.982 0.795 ]

To load this data into MATLAB, make sure you have lab4Data.mat in your working directory, and run the following line in your Command Window:

marsSamples = load(‘lab4Data-1.mat’, ‘data’).(‘data’)

What this is doing is loading from the file lab4Data.mat the part labeled ‘data’, and telling MATLAB the variable was stored as ‘data’, and we want to store it as ‘marsSamples’.

Convert the data from units of Celsius, Meters, and Kilograms to Fahrenheit, Feet, and Pounds using matrix arithmetic, and store the result in a matrix ‘marsSamplesConverted’.

Hint: To convert from Meters to Feet and Kilograms to Pounds, the value just needs to be multiplied by a constant. We can do this by multiplying by a vector! But when we convert from Celsius to Fahrenheit, we need to multiply by a constant and then add 32. We cannot do this with just one matrix operation. So one straightforward way to tackle the problem is to multiply our matrix by a vector to multiply each column by the necessary constants, then in another line of code worry about adding 32 to the first column only.

Measurements similar to these were actually taken to analyze Mars landings:

Rock size‐frequency distributions on Mars and implications for Mars Exploration Rover landing safety and operations (Links to an external site.)

2. For this next exercise, suppose you are an employee of the Poway Waste Water Plant. It has an open air plan, similar to the picture below.

wasteWater.jpg

Your supervisor, (who has just informed you that you will have to work overtime this weekend), has fallen into pool of poopy water you are observing. We wish to model the surface of the waste water, mostly to see if you will get wet from the ripple effect. You have calculated the distance from where your supervisor will fall to points around the pool, and stored them in a 50×50 matrix.

To load this matrix into MATLAB, make sure you have lab4Data.mat in your working directory, and run the following line in your Command Window:

wasteWaterDistance = load(‘lab4Data-1.mat’, ‘dist’).(‘dist’)

Below are the first few entries of the matrix:

LaTeX: \begin{bmatrix}<p data-verified=33.234 & 32.535 & 31.851 & \\

32.535 & 31.820 & 31.121 & \cdots\\

31.851 & 31.121 & 30.406& \\

\vdots & & & \ddots

\end{bmatrix}”>

[ 33.234 32.535 31.851 32.535 31.820 31.121 ⋯ 31.851 31.121 30.406 ⋮ ⋱ ]

This means the location corresponding to the entry 1,1 is 33.234 meters from where your supervisor has fallen in.

The ripple your supervisor creates across the surface follows a sinusoidal pattern, with an initial amplitude of 1 meter. To make an approximate model of the surface shortly after your supervisor falls, we take the sine of the distance from where your supervisor fell in, divided by the distance. Calculate this using matrix arithmetic, store the result in a matrix ‘ripple’, then plot the result with surf(ripple). You can play with the plot with the rotate and zoom tools in the toolbar. Finally, you are standing in the location corresponding to the matrix entry 20,18, and are 10 cm from the surface. Do you get wet from the ripple?

TURN-IN INSTRUCTIONS

Create a script called lab4.m. Your script should include your name and each problem description in comments.

SAMPLE ASSIGNMENT
Powered by WordPress