Suppose you have a matrix , x containing the scores of students in a class. Five
ID: 3792095 • Letter: S
Question
Suppose you have a matrix , x containing the scores of students in a class. Five tests were given. All scores lie in the range of 0-100. The matrix consists of the following:
Column 1 : The U-Number of each student
Column 2: Test scores of all students in Test 1
Column 3: Test scores of all students in Test 2, etc.
(a) Write Matlab code to create a vector z, containing the average score of each student in the five tests.
(b) Write a code to arrange the elements of z created above in descending order.
(c) Write a Matlab code to create a vector that contains the maximum score attained in each test.
(d) Write a code to determine median score attained in each test.
Explanation / Answer
% Here A is matrix as per requirement
% first column is U_number of next five is score in each test of each student
A=[1 23 45 34 51 44
2 76 62 43 82 45
3 45 56 56 43 54
];
% Copy A into B
B=A
% This command skips the first column which is U_number and store only test score in B
B(:, 1) = [];
% Calculate average score of each student and store it in a vector
getans=mean(B.')
% Sort the vector in descending order
getans = sort(getans,'descend')
% Calculate the maximum score in each test and store it in a vector
vv=max(B)
% Calculate median of each test and store it in a vector
med=median(B)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.