Matlab Grader - Determining if a variable is a function handle.
显示 更早的评论
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
Could you give us an example of a variable that is not a function handle but returns true when tested with the isa() function you shared?
Justin Wyss-Gallifent
2020-6-15
strcmpi(class(f),'function_handle')
Justin Wyss-Gallifent
2020-6-15
Justin Wyss-Gallifent
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.
Justin Wyss-Gallifent
2020-6-15
采纳的回答
更多回答(0 个)
社区
类别
在 帮助中心 和 File Exchange 中查找有关 Use Content in an LMS Course 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!