
Some scripts work with assessment test variables, others don’t and plots seem suppressed in feedback , Matlab Grader
5 views (last 30 days)
Show older comments
Hi,
I'm running into two issues in MATLAB Grader and was hoping for clarification:
- Inconsistent script behavior:I’ve copied multiple problems using scripts (not functions). In some cases, the script works fine when the variables are defined in the assessment test (e.g., setting values like m = 2; l = 1.5; k = 100; in the test and then running the solution. But in other cases, even with the same approach, the script doesn't pick up the test-defined variables unless they’re hardcoded inside the student’s script. Why do some scripts work and others don’t in this context? Is there a rule or limitation I’m missing?
- Plots in assessment tests not visible:I’d like to show a plot to the student when their answer is wrong (e.g., overlaying their result and the expected result). But when I include plotting code in the assessment test, nothing appears even when I know the code is running. Are plots from assessment tests intentionally suppressed? Is there a supported way to display figures to students as part of automated feedback?
Thanks in advance for any help or tips!
0 Comments
Answers (1)
Cris LaPierre
on 4 Aug 2025
For the first question, I can't think of a situation that would cause this behavior. I would be very interested in seeing an example of a problem that is not working. To diagnose, I'd like to see the reference solution, learner solution, and assessment test. One thing to consider is the order fo execution in script-type problems. When submitting, first the Reference Solution is run. All variables in the Workspace are added to the structure referenceVariables and then cleared. The Learner Solution is then run, and finally each assessment test in order. Each assessment test, then, has access to the Workspace, which contains the variables created by the learner solution, to the referenceVariables structure, which contains the variables created by the Reference Solution, and then any variables created in that assessment test. Variables created in one assessment test cannot be accessed in other assessment tests.
For #2, assessment tests are designed to not display any output to the learner - variable values or figures. When I want to show the learner a plot, I include an image of the plot in the assessment test feedback. If you have access to the Getting Started with MATLAB Grader collection, check out assessment #4 in the 'Determine the drag coefficient by fitting a polynomial to velocity-force data' problem for an example.

0 Comments
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!