Using Matlab classes in Grader

4 ビュー (過去 30 日間)
Attila
Attila 2023 年 6 月 6 日
コメント済み: Attila 2023 年 6 月 6 日
I would like to use a Matlab class in Grader. The students should define a class myclass which is also implemented in the reference solution. According to the Matlab help,I use function based assessments:
%Student solution
y = myclass([1 2 3], 1)
% Run reference solution.
yReference = reference.myclass([1 2 3], 1)
% Compare.
assessVariableEqual('y', yReference);
The Pretest results say:
Variable y must be of data type reference.myclass. It is currently of type myclass. Check where the variable is assigned a value.
How should I solve this?
Thank you in advance!

回答 (1 件)

Cris LaPierre
Cris LaPierre 2023 年 6 月 6 日
編集済み: Cris LaPierre 2023 年 6 月 6 日
In my opinion, classes go a bit beyond what MATLAB Grader was designed for. Still, it is possible to create and use classes in a function-type problem in a somewhat limited manner. However, the assessVariableEqual function cannot be used to assess a class object directly.
Assessments that work
  • Check for the presence of methods by name
  • use the methods and ismethod functions to query all public, non constructor and non set/get methods.
  • Use the properties function to determine what public properties the class contains.
  • Use dot notation to access the value of public properties.
  • assessVariableEqual can compare values
  1 件のコメント
Attila
Attila 2023 年 6 月 6 日
Thank you very much

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCreate or Copy Coding Problems についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by