フィルターのクリア

Group a function's input arguments into a matrix input argument

1 回表示 (過去 30 日間)
Gabriele
Gabriele 2024 年 2 月 7 日
コメント済み: Walter Roberson 2024 年 2 月 7 日
I'm generating two separate functions from symbolic expressions that share parameters so i can fit two datasets simultaneously.
However, each symbolic expression uses upwards of 6 input parameters plus the variable, and the function handle specifies them all individually. For the simultaneous fitting I need al those input variables (the parameters) to be grouped up into a matrix so I can generate a composite function that will fit both datasets simultaneously to the same parameters.
How do I group these input variables in the function @(A0,k1,k2,k3,k4,k5,tau)-... into a function @(par,tau)-....
where par = [A0,k1,k2,k3,k4,k5] ?

採用された回答

Walter Roberson
Walter Roberson 2024 年 2 月 7 日
matlabFunction(EXPRESSION, 'vars', {[A0,k1,k2,k3,k4,k5], tau})
  2 件のコメント
Gabriele
Gabriele 2024 年 2 月 7 日
Thank you, this worked!
Walter Roberson
Walter Roberson 2024 年 2 月 7 日
Earlier you said
par = [A0,k1,k2,k3,k4,k5]
which is a row vector, but now you are saying
par=[1;
.9;
.6;
0.015;
0.045;
0.055];
which is a column vector.
You need to decide which it is; the 'Variables' mechanism cannot support arbitrary vectors.
If you want par to be a row vector then
SP1_fun = matlabFunction(SP1,'vars',{[A0,k1,k2,k3,k4,k5],tau});
If you want par to be a column vector then
SP1_fun = matlabFunction(SP1,'vars',{[A0;k1;k2;k3;k4;k5],tau});

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStructures についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by