octave - 来自 fminunc 函数的未定义参数错误
问题描述
我正在尝试将 fminunc 与在外部文件中定义的函数一起使用。我正在研究的文档显示了一个带有内联函数定义的示例,并且它有效。我试图将该函数移动到另一个文件,但无法运行。有人可以告诉我我做错了什么吗?
>> inlinetest = @(x) x(1)^2 - 3*x(1);
>> fminunc(inlinetest, [5])
ans = 1.5000
>> mytest(5)
ans = 10
>> fminunc(mytest, [5])
error: 'x' undefined near line 2 column 7
error: called from
mytest at line 2 column 5
error: evaluating argument list element number 1
>>
#mytest.m contents
function r = mytest(x)
r = x(1)^2 - 3*x(1);
endfunction;
解决方案
推荐阅读
- heroku - Heroku 使用调度程序重建和重新部署
- scala - 为什么 GraalVM CE 的吞吐量比 GraalVM EE 或 OpenJDK 8 小
- android - 无法运行 2 个连续测试(需要但未调用实际上,与此模拟的交互为零)
- reactjs - 如何在 ReactJS 中添加 altmetrics 徽章
- sqlite - 在 Room 中创建表格的方法
- nativescript - Nativescript 缺少虚线边框
- javascript - 需要帮助才能按键盘上的字母
- sql - ExecuteNonQuery 返回 0?
- wordpress - Wordpress 的页面编辑器更改为“块”格式,并丢失了主题组件
- python - 欧拉计划 #11 Numpy 方式