Sie sind auf Seite 1von 2

Name: Homework 2 HP102-01

This recitation requires the use of two external files, test scores.mat and sensor.mat. They are
available on moodle, please save them to the same folder your script is in.

Problem 1
Use the command load(’test scores.mat’) to import the following information into Matlab
(without the column headers). If done correctly, the variable test scores will load in your workspace.

Student No. Test 1 Test 2 Test 3


1 68 45 92
2 83 54 93
3 61 67 91
4 70 66 92
5 75 68 96
6 82 67 90
7 57 65 89
8 5 69 89
9 76 62 97
10 85 52 94
11 62 34 87
12 71 45 85
13 96 56 45
14 78 65 87
15 76 43 97
16 68 76 95
17 72 65 89
18 75 67 88
19 83 68 91
20 93 90 92

(a) An error was made in test recording; one student was given a 5 when they should have received
an 85. Find and correct this typo in test scores.

(b) Extract the scores and student number for student 5 into a row vector (1x4 matrix) named
student 5.

(c) Extract the scores for Test 1 into a column vector (20x1 Matrix) named test 1.

(d) Assuming that each test was worth 100 points, and tests count for 100% of student grades,
find each student’s final grade and store it in a matrix named final scores.
(Be careful not to add in the student number.)

(e) Combine the matrices test scores and final scores into a new matrix fixed test scores.

(f ) Save the matrix fixed test scores to a new file named final report.mat using the save()
function.

1
Name: Homework 2 HP102-01

Problem 2
Use the load() function on the file sensor.mat to import infromation collected by temperature
sensors into Matlab. The following indicates the format of the sensor data. If done correctly,
the variables sensor 1, sensor 2, sensor 3, sensor 4, and sensor 5 will load in your workspace
(without the column headers displayed below).

sensor 1

Time (s) Temp. (◦ F)


0 63.2436
1 75.8856
2 66.2243
3 70.5706
4 63.3129
5 72.0396
6 65.2594
7 73.0815
8 73.7842
9 74.9630
10 69.0108
11 61.6764
12 64.5795
13 78.2667
14 63.0475
15 76.5163
16 70.7668
17 79.9226
18 61.5635
19 68.8535

(a) Combine the temperature data from each sensor into one 20x6 Matrix.
(Column 1 should be time, Column 2 should be sensor 1’s data, Column 3 should be sensor 2’s data, etc.)

(b) Find both the maximum value and the minimum value recorded on each sensor and at what
time each of these extrema occur.
(Hint: You don’t need to use anything other than max() and min() for this. Use help max and help min
to find information of the index of the maximum or minimum.)

(c) Find the mean and standard deviation for the data collected by each sensor.
(Hint: The functions mean() and std() will be useful. Again, use the help function or the MathWorks
website.)

(d) Find the mean and standard deviation for the data collected by all sensors.
(Remember, column 1 does not contain sensor data; it contains time data.)

Das könnte Ihnen auch gefallen