Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
how to get the detailed values from a linear model class?

Subject: how to get the detailed values from a linear model class?

From: James Anderson

Date: 5 Mar, 2013 21:00:09

Message: 1 of 3

I am using the example on the mathworks website:

http://www.mathworks.com/help/stats/linearmodel.disp.html

X = randn(100,5);
y = X*[1;2;3;4;5] + 6 + randn(100,1);
mdl = LinearModel.fit(X,y);

one silly question is that how to get the values of those model details from mdl? I can easily see them, but not sure how to output them or assign to a variable in matlab.

Thanks,

-James

Subject: how to get the detailed values from a linear model class?

From: Alan_Weiss

Date: 6 Mar, 2013 12:45:30

Message: 2 of 3

On 3/5/2013 4:00 PM, James Anderson wrote:
> I am using the example on the mathworks website:
>
> http://www.mathworks.com/help/stats/linearmodel.disp.html
>
> X = randn(100,5);
> y = X*[1;2;3;4;5] + 6 + randn(100,1);
> mdl = LinearModel.fit(X,y);
>
> one silly question is that how to get the values of those model
> details from mdl? I can easily see them, but not sure how to output
> them or assign to a variable in matlab.
> Thanks,
>
> -James

Not a silly question at all! To get the formula, enter
mdl.Formula

To get the coefficients, enter
mdl.Coefficients

To see what else is lurking in the model, double-click it in the
Workspace browser, or look at the documentation of the class:
http://www.mathworks.com/help/stats/linearmodelclass.html

Alan Weiss
MATLAB mathematical toolbox documentation

Subject: how to get the detailed values from a linear model class?

From: James Anderson

Date: 6 Mar, 2013 18:26:09

Message: 3 of 3

Thank, Alan! That works.

-James
Alan_Weiss <aweiss@mathworks.com> wrote in message <kh7dpa$spv$1@newscl01ah.mathworks.com>...
> On 3/5/2013 4:00 PM, James Anderson wrote:
> > I am using the example on the mathworks website:
> >
> > http://www.mathworks.com/help/stats/linearmodel.disp.html
> >
> > X = randn(100,5);
> > y = X*[1;2;3;4;5] + 6 + randn(100,1);
> > mdl = LinearModel.fit(X,y);
> >
> > one silly question is that how to get the values of those model
> > details from mdl? I can easily see them, but not sure how to output
> > them or assign to a variable in matlab.
> > Thanks,
> >
> > -James
>
> Not a silly question at all! To get the formula, enter
> mdl.Formula
>
> To get the coefficients, enter
> mdl.Coefficients
>
> To see what else is lurking in the model, double-click it in the
> Workspace browser, or look at the documentation of the class:
> http://www.mathworks.com/help/stats/linearmodelclass.html
>
> Alan Weiss
> MATLAB mathematical toolbox documentation

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us