How to set a parameter lower bound during curve fitting?
30 次查看(过去 30 天)
显示 更早的评论
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!
0 个评论
采纳的回答
Adam Danz
2018-7-25
编辑:Adam Danz
2018-7-25
Here's how you set bounds using fit()
See 'Lower'.
3 个评论
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"
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Linear and Nonlinear Regression 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!