Trying to make a regression model; question about fitlm and intercept!
Show older comments
Hi.
So I am trying to make a simple regression model for my measurement data. I used the following code:
function regg2
x=[19.8044 19.8044 19.8044 19.8044 19.8044 19.8044 19.8044 19.8044 35.278 35.278 35.278 35.278 35.278 35.278 20.0042 20.0042 20.0042 20.0042 20.0042 20.0042 25.3008 25.3008 25.3008 25.3008 25.3008]';
y=[4.5 7 2 2 4 6 5 6.8 1 0 0 0.4 1 0 10 2 5 8.1 1.9 2 4.6 3.6 10 1.6 0.8]';
mdl= fitlm(x,y)
plotAdded(mdl)
And I get this nice little figure:

But I discussed this with my teacher and he seem to think it is not correct. He says that my model should have an intercept. The fitlm gives me intercept of 10 which means that b0 is approx. 1. But it does not seem to be the case.
I am sorry if I am a bit unclear. But the idea is to make a simple linear regression model and get the standard equation which would normally be:
y=b0+b1*x1
Am I misunderstanding the method? Am I wrong? If I am wrong, how should I go about my code to get my regression model and a similar figure?
Thanks in advance!
Accepted Answer
More Answers (0)
Categories
Find more on Gaussian Process Regression in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!