How to concatenate output of objective function for lsqcurvefit?

1 回表示 (過去 30 日間)
Hashim
Hashim 2021 年 11 月 21 日
編集済み: Hashim 2021 年 11 月 23 日
Hi All,
I have an objective function of the form
function [I_num] = PSw_EK_v7(k_m, s_bulk)
k_m is the variable I want to optimize while s_bulk is an array of input data which I want to feed the input function. I am using the lsqcurvefit/lsqnonlin function to fit my simulation to experimental data of the form.
s_bulk = [0, 5e-06, 10e-06, 20e-06, 50e-06, 100e-06];
I_exp = [0, 2.35e-03, 2.7e-03, 3.125e-03, 3.29e-03, 3.25e-03]
Now what I am trying to do is feed the lsqcurvefit function my s_bulk array and get an array of I_num values but I am having difficulty doing that. I have tried arrayfun function but that does not seem to work inside the lsqcurvefit function.
So, to put things short I want to give my s_bulk array and get an array of I_num because that is what lsqcurvefit expects.
[k_m,resnorm,residual,exitflag,output]=lsqcurvefit(@PSw_EK_v7, k_m_0, s_bulk, I_exp, lb, ub, options);
  4 件のコメント
Matt J
Matt J 2021 年 11 月 21 日
編集済み: Matt J 2021 年 11 月 21 日
Also, can you provide to us k_m_0, lb, and ub?
Hashim
Hashim 2021 年 11 月 21 日
lb = 1e06;
ub = 1e09;
k_m_0 = 1.9e07;

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

採用された回答

Matt J
Matt J 2021 年 11 月 21 日
c0 = [ic_arg{1}(x).'; ic_arg{2}(x).'; ic_arg{3}(x).'];
  19 件のコメント
Hashim
Hashim 2021 年 11 月 23 日
編集済み: Hashim 2021 年 11 月 23 日
Hi, it might be working, let me confirm it and get it back to you. Apparently the execution time is increased manyfolds when I run it this way. And please accept my humble gratitude for your help so far. Is there any way I can get the I_anodic as an output while calling lsqcurvefit?
Matt J
Matt J 2021 年 11 月 23 日
編集済み: Matt J 2021 年 11 月 23 日
Yes, it will be 6 times slower because lsqcurvefit needs to run the ODE solver for each i=1...6.

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

その他の回答 (0 件)

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by