MATLAB Grader marks my submission as incorrect if it contains statements like "clc" and "clear all"

8 views (last 30 days)
In MATLAB Grader, some assessment tests are being marked incorrect even when I have confirmed that the submitted solution is correct.
I noticed that my submission contains commands like "clc" and "clear". Do they have to do anything with submission.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 12 Mar 2021
Edited: MathWorks Support Team on 12 Mar 2021
This is expected behavior. The reason for that is because "clear" removes all the variables created in the reference solution. These variables are often used to compare against variables created in the learner solution. This results in the Variable Equals Reference Solution test type, and any assessVariableEqual tests comparing to a referenceVariable field, to be marked incorrect.
As a possible workaround, the instructors can include the following command when creating questions.
assessFunctionAbsence('clear', 'Feedback', 'Do not use clear in your solution');
Please refer to following documentation page for details about "assessFunctionAbsence" function.
  1 Comment
Cris LaPierre
Cris LaPierre on 9 Mar 2021
Edited: Cris LaPierre on 9 Mar 2021
Let me add a couple clarifications. First, there is no error message. The observed effect is that some assessment tests may always be marked incorrect even when it has been confirmed the submitted solution is correct.
In addition, clc has no effect. The only issue is due to using clear.
The reason for that is because clear removes all the variables created in the reference solution. These variables are often used to compare against variables created in the learner solution. This results is the Variable Equals Reference Solution test type, and any assessVariableEqual tests comparing to a referenceVariable field, to be marked incorrect.

Sign in to comment.

More Answers (0)

Products


Release

R2017b

Community Treasure Hunt

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

Start Hunting!