How do I test plots produced by students' code in Cody Coursework?

2 ビュー (過去 30 日間)
With the introduction of Cody Coursework, I'm sometimes asked how to test plots or user interface components generated by students' code.

採用された回答

MathWorks Community Team
MathWorks Community Team 2014 年 2 月 27 日
編集済み: MathWorks Community Team 2014 年 6 月 9 日
When testing plots, remember Cody Coursework executes students' code using a hosted MATLAB server. This means it will not be showing or displaying the graphics. Still, the MATLAB runtime offers access to the graphics objects' plot properties via the figure handle. Thus, you can interrogate properties and ensure the student's code is doing what's expected. Here's an example:
Test Suite:
h = student_plot();
students_linewidth = get(h, 'LineWidth');
assert(isequal(students_linewidth,0.5),'your linewidth is incorrect');
Reference Solution:
function h = student_plot( )
x=[0:0.01:6.28];
y=2*x.*sin(x);
h=plot(x,y);
end
Remember, Cody Coursework Test Suites give you the full power of the MATLAB language to creatively automate assessment of students' code.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTest Execution についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by