How to fix the coefficients values using the fitnlm() function
显示 更早的评论
Hi all,
I am trying to use non linear regression fit using the fitnlm function. Is there a way to fix a specific
coefficient to a known value? in this specific case I would like to fix b(2) to 50.
Thank you in advance for your help.
I report here my code
x = data (:,1);
y = data (:,2);
plot (x, y, 'o')
hold on
%----- Model function for 1:1 binding -------
b0 = [0.06; 50; 0.5];
modelfun = @(b,x)b(1)*(b(2)+x+b(3)-sqrt((b(2)+x+b(3)).^2-4*b(2)*x))./(2*b(2));
%options for fitnlm
options = statset('Display','iter','TolFun',1e-10)
modelFit=fitnlm(x,y,modelfun, b0,'Options',options)
results=table2array(modelFit.Coefficients)
plot(x, modelfun(results(:,1), x))
hold off
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!