How to set a parameter lower bound during curve fitting?

Hello, I want to set the lower bound for my p2 variable as 0, because a negative value is unphysical for my data set.
Here is my code:
rho=Resistivityohmcm; T=TemperatureK;
plot(T,rho,'-o')
x=T; y=rho;
fnPolySq=@(p1,p2,x) p1*x.^2 + p2; %fit(x,y,fnPolySq) mask = x > 135 ; %restricts the data fit to before the upturn
f = fit(x(mask), y(mask), fnPolySq ); plot(f, T, rho)
plot(f,T,rho) disp (f)
Thanks!

 採用された回答

Adam Danz
Adam Danz 2018 年 7 月 25 日
編集済み: Adam Danz 2018 年 7 月 25 日

0 投票

Here's how you set bounds using fit()
See 'Lower'.

3 件のコメント

Alexandria Will-Cole
Alexandria Will-Cole 2018 年 7 月 25 日
I tried what is stated in the link...
f = fit(x(mask), y(mask), fnPolySq,'StartPoint',[0,0] );
However, I still get a negative value for p2... General model: f(x) = p1*x.^2+p2 Coefficients (with 95% confidence bounds): p1 = 1.054e-07 (1.051e-07, 1.058e-07) p2 = -0.0005989 (-0.0006185, -0.0005792)
Can you elaborate on how to resolve this please?
Adam Danz
Adam Danz 2018 年 7 月 25 日
In the line of code you shared, I don't see where you've implemented the 'Lower' parameter. See the link again and read the section, " 'Lower' — Lower bounds on coefficients to be fitted"
Alexandria Will-Cole
Alexandria Will-Cole 2018 年 7 月 25 日
Thanks!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeGet Started with Curve Fitting Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by