Help with assessing learners work

1 visualización (últimos 30 días)
Kuda
Kuda el 22 de En. de 2025
Editada: Cris LaPierre el 24 de En. de 2025
Hi All,
I am trying to assess students work for a reference solution below, but the problem is that when one thing is wrong, it is marking everything as wrong even though some elements of the learner's code are correct. For example, say, UTM is correct but RREF is wrong, the assessment will also assess UTM as wrong. Is there a way I can fix this
function [AI UTM RREF INVA] = ROINVERSE(A)
%% Step 1: Matrix Validation
% Establish the Size of the Matrix [m n]
[m n] = size (A) ;
% Check if the Matrix is Square
if m~=n
error('Matrix Is Not Square') ;
% Check Matrix For Singularity
elseif det(A) == 0
error('Matrix Is Not Invertible Since |A|=0') ;
% Inform The User The Matrix Can Be Inverted
else
disp('The Matrix Is Invertible') ;
end
%% Step 2: Augmented Matrix AI
AI = [A eye(m)] ;
%% Step 3: Upper Triangular Matrix UTM
UTM = AI ;
for i = 1:m
% Making All The Pivots = 1
UTM(i,:) = UTM(i,:)./UTM(i,i)
for j = i+1:n
% Making Values Below Pivots Equal to Zero
UTM(j,:) = UTM(j,:)-UTM(j,i)*UTM(i,:)
end
end
%% Step 4: Reduced Row Echelon Form RREF
RREF = UTM ;
for k = 1:(m-1)
for l = k+1:n
RREF(k,:) = RREF(k,:)-RREF(k,l)*RREF(l,:)
end
end
%% Step 5: Extract The Inverse Matrix INVA
INVA = RREF(1:m,(n+1):end)
end
  2 comentarios
Kuda
Kuda el 22 de En. de 2025
Below is an example of the test codes I am using
% UTM Check
A = [2 1; 7 4];
[~, UTM, ~, ~] = ROINVERSE(A);
expected_UTM = [1 0.5 0.5 0; 0 1 -7 2]; % Manually calculate this
assert(isequal(round(UTM, 5), round(expected_UTM, 5)), "Upper triangular matrix UTM is incorrect.");
% RREF Check
A = [2 1; 7 4];
[~, ~, RREF, ~] = ROINVERSE(A);
expected_RREF = [1 0 4 -1; 0 1 -7 2]; % Manually calculate this
assert(isequal(round(RREF, 5), round(expected_RREF, 5)), "RREF is incorrect.");
Cris LaPierre
Cris LaPierre el 24 de En. de 2025
Can you share an example?
When I modify the code that creates RREF but not UTM and then run your assessment tests, UTM is marked correct and RREF is marked incorrect, as you desire.

Iniciar sesión para comentar.

Respuestas (1)

Cris LaPierre
Cris LaPierre el 24 de En. de 2025
Editada: Cris LaPierre el 24 de En. de 2025
Given my comment above, I wonder if the learner solution contains a syntax error.
If yes, then everything is marked incorrect. Incorrect assessments return an error. Here, the solution code is throwing the error, not the assessment tests. The result is that all tests are determined to be incorrect. In this case, the syntax error must be fixed before the assessment tests can perform as expected.
The Output section and the red default feedback will contain the error message. Learners can also use 'Open in MATLAB Online' to see the output as it would appear in MATLAB, which might help with debugging.
So, for example, if introduce the following syntax error:
RREF(k,:) = RREF(k,:).-RREF(k,l)*RREF(l,:)
% ^
MATLAB Grader will display these results:

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by