MATLAB Grader: What should my assessment return when it determines a student solution is correct or incorrect?
Show older comments
Let's say the assignment is to create (and leave open) a figure with three subplots and one of the subplots should have the title "Oscillating Motion". I want to use an assessment of Test Type MATLAB Code to check the figure the student's code has created. I can easily check that using Matlab code similar to the following
% Get the handles of all subplots
axis_handles = findobj(gcf, 'type', 'axes');
% see if the title matches the requirement
set_required_title = false;
for axnum=1:length(axis_handles)
title_str = get(get(axis_handles(axnum),'Title'),'String');
set_required_title = set_required_title | strcmpi(title_str,'Oscillating Motion');
end
How do I return that result (the variable set_required_title) as an assessment test?
BTW, just for context of what I am talking about, in my LMS, this looks like

Accepted Answer
More Answers (1)
Cris LaPierre
on 4 Apr 2024
Edited: Cris LaPierre
on 8 Apr 2024
1 vote
Please see this Answer: https://www.mathworks.com/matlabcentral/answers/548631-matlab-grader-determining-if-a-variable-is-a-function-handle#answer_451644
Your assessment must return an error if the answer is incorrect. Otherwise, it is considered correct. This is what assert, as well as the built-in assessment functions do.
2 Comments
Cris LaPierre
on 4 Apr 2024
Since you are grading a plot, I suggest also looking at this answer. It shows how to build a more robust custom assessment test so that students alway receive meaningful feedback.
M. E. Brokowski
on 7 Apr 2024
Categories
Find more on Use Content in an LMS Course in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!