フィルターのクリア

Fitting a function of the form x-a for unknown a

1 回表示 (過去 30 日間)
Shawn
Shawn 2014 年 9 月 3 日
コメント済み: Shawn 2014 年 9 月 23 日
We have data which is roughly exponential for x<a, and approximately a power law (x-a)^b for x>a, but I'm unclear how (or if it's even possible) to find a adaptively.
Clearly fitting a function of the form Ce^(bx)+ c(x-a)^d is a problem (if for no other reason than the fact that 0<x<a gives complex value), but short of brute force trial and error to find a, I'm not quite sure where to start.
I guess I'm looking to optimize the value of a by simultaneously fitting the exponential below and the power law above until both converge (though I'm pretty sure that's not possible without a fair amount of work).

採用された回答

Roger Wohlwend
Roger Wohlwend 2014 年 9 月 4 日
Yes, you're looking for an optimization, and I can assure you that it is not a fair amount of work. However it won't work with the function you mention in your question. Instead use the optimization function lsqcurvefit with the following function you want to fit:
function y = myoptfunc(coeff, xdata)
y = NaN(length(xdata),1);
q = xdata < coeff(1);
y(q) = coeff(2) * exp(coeff(3) * xdata(q));
y(~q) = coeff(4) * (xdata(~q) - coeff(1)).^coeff(5);
end
The vector coeff contains your coefficients. The first one is your parameter a.
  1 件のコメント
Shawn
Shawn 2014 年 9 月 23 日
Cheers, thanks. Sorry for the delay in getting back to this, life intervened! I'll have a play with the method you suggested and see how it goes, it looks generally useful for us for some other types of fitting we need to do as well.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by