lsqcurvefit claiming complex-valued function
4 ビュー (過去 30 日間)
古いコメントを表示
I have a function which I am fitting data to to extract parameters F(1), F(2), F(3), and F(4)
fun = @(F,frequency) ((1j*2*pi*frequency).^F(1)*10^F(2)+1./(10^F(3))).^(-1)+10^F(4);
fit_function= @(F,frequency) log(real(fun(F,frequency)));
When I try to run the function to fit the data:
[best_fit,resnorm(i,j,k,l)] = lsqcurvefit(fit_function,guess,frequency,log(Real),lower_bound,upper_bound,options);
I am receiving an error:
Error using lsqncommon (line 35)
Lower and upper bounds not supported with complex-valued initial function or Jacobian evaluation.
Although the fiting function fit_function is the log of a real valued part of the function, why is it considering that the function is complex? I removed the log to make sure it is not taking the log of negative values.
0 件のコメント
回答 (2 件)
Torsten
2024 年 2 月 12 日
移動済み: Torsten
2024 年 2 月 12 日
Although the fiting function fit_function is the log of a real valued part of the function, why is it considering that the function is complex?
Because the imaginary unit 1j is part of your function definition.
You should define your fitting function as
a*frequency^b + c
with a, b, c being constants to be fitted and constraint to be >=0.
The constants F(3) and F(4) cannot be estimated separately - they can only be used as one constant c > 0.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Interpolation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!