Matlab Grader - Determining if a variable is a function handle.
4 ビュー (過去 30 日間)
古いコメントを表示
Justin Wyss-Gallifent
2020 年 6 月 15 日
編集済み: Cris LaPierre
2020 年 6 月 15 日
I'm writing a Matlab Grader assignment in which I'd like the students to define a function, say f, as a function handle. I'd then like an assessment test which verifies this. I figured an assessment test in Matlab code which simply said:
isa(f,'function_handle')
would do the job but this registers as true (in Matlab Grader) even when f is not a function handle.
7 件のコメント
Adam Danz
2020 年 6 月 15 日
編集済み: Adam Danz
2020 年 6 月 15 日
Hmmmm..... that's fishy. So, the assert(isa(f,'function_handle')) line does throw an error when f is f=5? Why would the isa() function work when it's inside of assert() but not outside of assert()? Unfortunately I haven't used the grader and can't fiddle with it right now.
採用された回答
Cris LaPierre
2020 年 6 月 15 日
編集済み: Cris LaPierre
2020 年 6 月 15 日
Assessment tests must assert the result. They do not recognize logical results as answers to the test. So the issue is not that false is being marked as correct. The isa(f,'function_handle') is returning false. It is that no assert has told Grader the result is incorrect.
Put another way, assessment tests are correct unless the code returns an error. Assert throws an error if the condition is false. So does the built-in assessVariableEqual function.
2 件のコメント
その他の回答 (0 件)
コミュニティ
その他の回答 遠隔学習コミュニティ
参考
カテゴリ
Help Center および File Exchange で Resizing and Reshaping Matrices についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!