export function as a string after fitting with linear model

1 view (last 30 days)
Hi all, I'm using stepwiselm for regression. The function returns a LinearModel with a lot of stuff in it. It seems difficult however, to extract the exact function from the linear model as a string. In this way I could print it in a textfile. So given the example
load carbig
tbl = table(Acceleration,Displacement,Horsepower,Weight,MPG);
mdl1 = stepwiselm(tbl,'ResponseVar','MPG','Upper','quadratic')
I'm looking for a way to get a result like this
model = 'MPG=63.558-0.25084*Horsepower-0.010772*Weight+5.3554e-05*Horsepower*Weight' Is there an (easy) way to do this? Thanks, Steven

Answers (0)

Community Treasure Hunt

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

Start Hunting!