Each column (except last) of matrix X contains students' scores in a course assignment or a test. The last column has a weighted combination of scores across all the assignments and tests.
Replace the elements in the last column of this matrix with a GPA calculated based on the following scale:
Score GPA 90 - 100 3 - 4 80 - 90 2 - 3 70 - 80 1 - 2 60 - 70 0 - 1 Below 60 0
Assume that no student in this class has scored below 60. Also note that the mapping in the range [60, 100] is linear.
See https://www.mathworks.com/help/matlab/ref/rescale.html
Example
Input:
100 90 95 95 70 50 60 60 80 70 90 80
Output:
100 90 95 3.5 70 50 60 0.0 80 70 90 2.0
It appears the last column of the output from the problem statement should be 3.5; 0.0; 2.0 instead of 3.5; 0.0; 3.0, but the first test suite does have it correct.
yes true, thank you
Thank you! Modified the problem statement.
Why doesn't it work?
function X = rescale_scores(X)
X = [X(1:end,1:end-1) (X(1:end,end).-60)./4]
end
it is ridiculous but still, it works. feel free to improve it.
function X = rescale_scores(X)
t=zeros(size(X,1)+2,size(X,2));
adjustment=[60;100];
t(1:end-2,1:end)=X;
t(end-1:end,end)=adjustment;
initial_finals=rescale(t(:,end),0,4);
X(:,end)=initial_finals(1:end-2,:);
end
A= 60:0.1:100;
A_reescale= rescale(A,0,4);
for c=1:size(X,1);
for d=1:size(A,2);
if X(c,(size(X,2)))==A(d);
X(c,(size(X,2)))=A_reescale(d);
end
end
end
Please, what is wrong with the following answer
X = (X-60)/10;
thank u
This would operate on the entire matrix X. However we want the GPA to appear only in the last column of X. So try by declaring another variable which would calculate the GPA and then replace the last column of X with this column vector.
We have to modify only last column of matrix X not an entire matrix so find GPA for that column only.
724 Solvers
Return the first and last character of a string
2555 Solvers
Generate a random matrix A of (1,-1)
218 Solvers
The sum of the numbers in the vector
380 Solvers
484 Solvers