gpt4 book ai didi

matlab - matlab中的函数句柄错误

转载 作者:太空宇宙 更新时间:2023-11-03 20:07:37 25 4
gpt4 key购买 nike

我想调用函数句柄 model_jacobian,但我得到“Error using ==> horzcatCAT 参数尺寸不一致。”。当我选择将 ad coefs 保留在雅可比矩阵中的函数时,一切正常。

syms a d x;  
syms_function = a*x+d;
model_jacobian = matlabFunction(jacobian(syms_function, [a d]), 'vars', {[a d], x});
J = model_jacobian([1 1], [1 2 3 4 5 6 7 8 9]');

那么如何调用带参数的函数句柄,尽管它们并没有在那里使用?

最佳答案

您可能已经解决了这个问题,但您可能需要重新考虑您的 vars 规范。文档说:

The value of this parameter must be either a cell array of strings or symbolic arrays, or a vector of symbolic variables

您有一个符号变量元胞数组,这似乎不正确。我会保持简单,例如:

'vars',[ a d x])

关于matlab - matlab中的函数句柄错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12246748/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com