Using an array as input argument of a function handle

6 ビュー (過去 30 日間)
Julen Paniagua
Julen Paniagua 2020 年 5 月 12 日
コメント済み: Julen Paniagua 2020 年 5 月 12 日
Hi,
I have a jacobian matrix created using symbolic variables and I was evaluating it using "subs" command. However, I was recommended to use matlabFunction and handleing it as a function handle. The dymensions of the jacobian matrix depend on my system structure and therefore its size is variable, so I am trying to create a generic code.
There is no problem creating the function handle.
(...some code)
% Function handle of Jacobian
J = matlabFunction(J);
and J is:
J =
function_handle with value:
@(V1,V2,V3,V4,theta1,theta2,theta3,theta4)reshape...
My problem comes here. If I design input arguments using a variable which is an array:
a = [1,1,1,1,0,0,0,0];
J_num = J(a);
I get the following error:
Not enough input arguments.
Error in
symengine>@(V1,V2,V3,V4,theta1,theta2,theta3,theta4)reshape([V1.*V2.*cos...
However, If I put it like this it works perfectly:
J_num = J(1,1,1,1,0,0,0,0);
Can anyone can help me?
Thank you in advance!!!

採用された回答

James Tursa
James Tursa 2020 年 5 月 12 日
c = num2cell(a);
J_num = J(c{:});
  1 件のコメント
Julen Paniagua
Julen Paniagua 2020 年 5 月 12 日
Thank you very much James!!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSymbolic Math Toolbox についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by