CSCI 1320 Computer Science I: Engineering Applications
A. Working with data files in MATLAB (70 points)
Large amounts of data can become useful if the information is organized and
presented visually. Following are the goals of this assignment:
1. Read in data files. Use xlsread MATLAB function to read in an Excel
spreadsheet. Perform some initial cleaning on the imported data, and then
save the cleaned data in MATLAB’s native data format.
2. Write a program that loads the cleaned data and uses it to calculate the grade
for each student.
During the Fall 2015 semester, 101 CU Boulder students took a quiz. The quiz
consisted of 17 multiple-choice questions, and 1 essay question. Your task is to
compute the final quiz scores and to plot a histogram of the scores.
What is given?
You are given one file named section9_data.xlsx which contains (see figure below):
I. The answer key for the multiple-choice part of the quiz (cells G2:W2),
II. The student ID numbers (column B),
III. The score the students received for the Essay portion of the quiz (column E),
IV. The section number (column F),
V. The student answers to each of the 17 multiple-choice questions (columns G
What do you need to do:
1. Read in the spreadsheet and clean up the data.
a. Read in the data using the xlsread() MATLAB function.
b. We only need the I, II, III, and V parts of data. We do not need to keep
any of the column titles. Create separate cell arrays that contain only
those parts of the data. Even though you are separating your data into
multiple arrays, make sure the row numbers will still correspond to
the correct student ID numbers, the answer key column numbers
correspond to the correct question numbers, etc.. (You do not need to
come up with an algorithm for detecting where the real data
starts/ends. You can hard code these indexes.)
c. Save only the data that is needed in the MATLAB native file format.
2. Load cleaned data and calculate grades.
a. Read in the MATLAB data file you created in previous part.
b. Calculate each student’s grade. The multiple choice part of the quiz
should be worth 60% of the grade and the essay should be worth
40%. Use the same letter-grade-to-score mapping as used in our
c. Display each student’s ID along with the grade they received on the
B. Intro to C++ (30 points)
Earlier on in the semester we wrote simple calculator script in MATLAB. Now, let’s
do the same in C++.
Problem description: write a program that prompts the user to enter 2 numbers.
The two numbers should be stored in variables of floating point type. The results of
each of the following operations should be printed to the screen as a part of a
1. adding them together
2. subtracting the second from the first
3. multiplying them together
4. dividing the first by the second
5. the first to the power of the second
(You are welcome to experiment with writing the result of each operation to a
variable, or you can just print the results directly.)
NOTE: if your C++ file does not compile with standard g++ compiler in Jupyter
Hub you will get a zero on the C++ portion of the assignment (no partial
credit). This will be the case with all C++ assignments going forward.
C. Extra Credit (20pts)
Write a Matlab function that takes one input — an MxN matrix — and returns one output
— the row number of the matrix with the smallest row sum.
● Name the function min_row_sum
● Name the input matrix A
● Name the output min_row
● You are NOT allowed to use any built in function EXCEPT for the size()
● You must use for loops to solve this problem.
Let A = [1 2 3; 4 5 6]
Then min_row will be equal to 1
Submitting the assignment:
Zip all the .m and .cpp files together and submit the resulting .zip file through
Moodle as Assignment 6 by due date.