In MATLAB Grader, how can I capture the printed output of a script type problem?
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Benjamin Walker
le 29 Mar 2024
Commenté : Dyuman Joshi
le 30 Mar 2024
My understanding is that the expected way to capture the printed output of code is using evalc. I understand how I would do this for a function-type problem, but is there a name I can pass into evalc to call a learner's script for a script-type problem?
An example problem:
(a) Create a variable x=5
(b) Create a variable y=2*x, and display its value using the disp function. This should be the only output printed by your code.
I would like to be able to mark as incorrect submissions such as
x = 5
y = 2*x
disp(y)
to force students to learn how to use semicolons, etc.
I was envisioning something along the lines of
learner_output = evalc('learnerScript');
assert(strcmp(learner_output, reference_output))
3 commentaires
Réponse acceptée
Cris LaPierre
le 30 Mar 2024
You are correct. The only way to do this in Grader is to use evalc.
1 commentaire
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!