MATLAB: Is it possible to suppress the default error message of the function assessVariableEqual

assessvariableequaldistance_learningMATLABmatlab gradermatlab_grader

For my Matlab Grader Courses I use the build in function assessVariableEqual.
In order to give the students a better hint for the correct solution I define my own error messages with the keyword 'Feedback' in the function.
Sometimes the default error message is confusing for the students and I want to suppress the message, but there seems to be no possibility to do so.

Best Answer

There is currently no way to suppress the default feedback when using the built-in assessment function assessVariableEqual. The alternative is to instead perform the grading using assert statements. Assert will only show the message you provide (see tips below for more).
To duplicate the behavior of assesVariableEqual, you must
  • First determine if the student variable exists.
  • Next, determine if the student variable is the same data type as the reference variable.
  • Then determine if the student variable is the same size as the reference variable.
  • Finally, determine if all the values in the student variable are the same as the values in the reference variable. For numeric values, apply a tolerance.
The first 3 tests are necessary to ensure the values can be compared without causing an error.
Here's an example (untested):
% does variable f exist?
assert(exist('f')==true,'The submission must contain a variable named f')
% is f a double?
assert(isa(f,'double'),'Variable f must be of data type double.')
% check size
assert(all(size(f)==size(referenceVariables.f)),'Variable size is incorrect');
% Check values using assert
assert(all(abs(f-referenceVariables.f)<0.0001),'The variable f contains an incorrect value');