Why is the lsqnonlin function telling me I don't have enough input arguments?

2 ビュー (過去 30 日間)
Sakina
Sakina 2018 年 1 月 28 日
コメント済み: Star Strider 2018 年 1 月 29 日
I have the following main:
K0=[60.2,1.4,14.7,2.3e12];
[K, resnorm]= lsqnonlin(myfun, K0)
Given myfun:
function [ F ] = myfun( K )
d32e=[580.8045;643.367;698.974;522.9306;645.1539;672.7778;679.3988;422.6795;594.0621;715.9881;469.7453;574.4126;626.5233;758.8268];
F=PBE_FUNCTION(K)-d32e;
end
in Matlab 2015b.
When I attempt to run the main, I get:
Not enough input arguments.
Error in myfun (line 4) F=PBE_FUNCTION(K)-d32e;
Error in Main (line 4) [K, resnorm]= lsqnonlin(myfun, K0)
How can I make it run?
(Please note that the PBE_FUNCTION uses other functions in its script, dependent on K.)

採用された回答

Star Strider
Star Strider 2018 年 1 月 28 日
One problem is that you need to use ‘@’ to create a function handle for ‘myfun’ in the lsqnonlin call:
[K, resnorm]= lsqnonlin(@myfun, K0)
I cannot run your code, so I do not know is the only problem.
  2 件のコメント
Sakina
Sakina 2018 年 1 月 29 日
Adding the function handle changed the error message, leading me to another error in the PBE_FUNCTION, which was then easily resolved. Thanks!
Star Strider
Star Strider 2018 年 1 月 29 日
As always, my pleasure!

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by