Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
|
![]() |
#1 |
高级会员
注册日期: 2019-11-21
帖子: 3,006
声望力: 66 ![]() |
![]()
这有效(画出“空”图):
function testme plot(1) 这有效(返回1): function testme plot = @(x)x; plot(1) 这不是(错误:“未定义的函数或变量'图'。”): function testme if 0 plot = @(x)x; end plot(1) 这里发生了什么?为什么重写但未重新定义已定义的函数会导致该函数未定义? 注1:这不是内置函数专用的;以下代码返回相同的错误: function testme if 0 myfun = @(x)x; end myfun(1) function x=myfun(x) x=x*2; 注2:错误发生在函数环境中,而不是脚本中;以下代码不返回错误(并且绘制与第一个示例相同的空图): if 0 plot = @(x)x; end plot(1) 更多&回答... |
![]() |
![]() |