Module-1: Lecture 1.2-Tutorial Problem: Name Math Programming Thermodynamics Mechanics
Module-1: Lecture 1.2-Tutorial Problem: Name Math Programming Thermodynamics Mechanics
The following problem is tutorial problem solved this week. This will be useful to learn
how to manipulate arrays in MATLAB.
The following marks were obtained by six students in a class.
Name Math Programming Thermodynamics Mechanics
Amit 24 44 36 36
Bhavna 52 57 68 76
Chetan 66 53 69 73
Deepak 85 40 86 72
Elizabeth 15 47 25 28
Farah 79 72 82 91
Create a 6×3 matrix allMarks to contain marks of all six students for first three courses.
Marks for Mechanics course for the six students are stored in a different vector mechMarks.
The two arrays are given to you as:
allMarks = [24, 44, 36; 52, 57, 68; 66, 53, 69;
85, 40, 86; 15, 47, 25; 79, 72, 82];
mechMarks = [36, 76, 73, 72, 28, 91];
First, append marks for the Mechanics course to allMarks when received. After this
step, allMarks would be a 6×3 array. Thereafter, do the following computations:
1. Mechanics course was out of 50. Scale the marks of the last column of allMarks
to half. Thus, marks for Amit will be 18, and so no…
2. Chetan wants to know his marks. So, extract row 3 from allMarks array. Also
calculate his total marks.
3. Extract marks of our best students, Deepak and Farah for first three courses. In
other words, extract first three columns of rows 4 and 6. The resulting array is 2×3.
4. Calculate average marks obtained by all students in each of the four courses. The
command for average is mean, and for adding elements of a vector is sum.
5. Scale all the marks out of 10. In other words, divide the first three columns by 10,
and the last column by 5.