How to make intercept 0 in fitlm?

36 次查看(过去 30 天)
Hello,
i have this code here. I got my result for this code but I want the intercept to be 0. Does anyone know how to do that?
A = [3 ; 6 ; 9 ; 12 ; 15 ; 18 ; 21 ; 24];
b = [13.65249633; 27.43151638; 40.81176096; 54.58291934; 69.15880849; 82.02503856; 95.68163465; 1.10E+02];
mdl = fitlm(A,b,'linear','RobustOpts','off')
Result: Estimate SE tStat pValue
______ ______ ______ ________
(Intercept) -0.14799 0.27475 -0.53862 0.60954
x1 4.579 0.018137 252.47 2.6057e-13
is it possible to make the Estimated intercept 0? I am pretty sure that the estimated x1 will change in value and that's actually what I'm aiming for...
Thanks a lot!

采纳的回答

Rik
Rik 2018-6-12
If you just want the value for x1:
A = [3 ; 6 ; 9 ; 12 ; 15 ; 18 ; 21 ; 24];
b = [13.65249633; 27.43151638; 40.81176096; 54.58291934;...
69.15880849; 82.02503856; 95.68163465; 1.10E+02];
x1=A\b;
If you want to force the intercept to 0, you can find the solution in the fitlm doc:
mdl = fitlm(A,b,'linear','Intercept',false)%'RobustOpts','off' is the default

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Dimensionality Reduction and Feature Extraction 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by