When you do not know how to pull some information from a class, the best thing is to try using methods to learn what you can do.
mdl = fit(rand(10,1),rand(10,1),'poly2')
Linear model Poly2:
mdl(x) = p1*x^2 + p2*x + p3
Coefficients (with 95
p1 = -0.8558 (-4.362, 2.651)
p2 = 0.6407 (-3.374, 4.655)
p3 = 0.4551 (-0.5222, 1.432)
We have here a very simple fit result. As you see, this works, but it may not be clear how to have known it would work. Sometimes just trying things is sufficient.
And as much as I want to say this should be the logical thing to try, or that it is shown in the documentation, a reading of the docs for fit does not show me a spot where that is explicitly stated.
But if we want a clear list of the functions we can use to work with mdl, or extract information from it, we use methods.
Methods for class cfit:
argnames coeffnames dependnames fitoptions integrate numcoeffs probnames type
category coeffvalues differentiate formula islinear plot probvalues
cfit confint feval indepnames numargs predint setoptions
Hmm, so coeffnames is a method we can use. do you see, I was able to extract the names of the coefficients using one of the methods?
3×1 cell array
One of the other methods listed was coeffvalues. The name alone should give me a hint that coeffvalues might help in our quest.
-0.855805940768612 0.640653729424836 0.455095631339414
So we can simply and programmatically use the coeffvalues method to do what we wanted, and there WAS a simple way to have learned that.
A followup question asked how to extact the confidence intervals. Again, LOOK AT THE METHODS. One of them is named confint. Does that help? I think it might.
-4.36215292171444 -3.37378195209185 -0.522170718930676
2.65054104017722 4.65508941094152 1.4323619816095
The point is, when you have a class that you have never seen before, you can learrn much by using methods on the class object.
If you wish to get direct help, then we could have done this:
coeffvalues Coefficient values.
coeffvalues(FUN) returns the values of the coefficients of the
CFIT object FUN as a row vector.
The information is there on how to extract what you want.