How do I print/save parameters from fitnlm?

3 views (last 30 days)
Hello, my main objective is to run several excel arrays through a gaussian function and I would like to export certain information including the values from the fitnlm parameters because these correspond to things like peak phase shift and amplitude.
Ideally, each of these arrays will generate a plot of the fit vs. the actual data. It would be awesome to print each of these to an excel sheet with the parameter data I'm after. Is there any way to do those things? Thanks!

Accepted Answer

Walter Roberson
Walter Roberson on 18 Aug 2015
The output of fitnlm is a nonlinear model object. See http://www.mathworks.com/help/stats/nonlinearmodel-class.html
"To obtain any of these columns as a vector, index into the property using dot notation. For example, in mdl the estimated coefficient vector is
beta = mdl.Coefficients.Estimate "
  1 Comment
Anjodenunca
Anjodenunca on 18 Aug 2015
Edited: Anjodenunca on 18 Aug 2015
Okay I think I understand what you're saying. I apologize, I'm pretty inexperienced with matlab. So if I wanted to assign p(1) to a function from the following model g:
Nonlinear regression model:
y ~ p1*exp(( - 1*(nm - p2)^2)/((2*p3^2)))
Estimated Coefficients:
Estimate SE tStat pValue
__________ _______ ______ ___________
p1 5.1879e+05 5667.1 91.544 5.2609e-164
p2 591.95 0.44573 1328 0
p3 35.363 0.44828 78.887 1.4976e-151
I would use something like beta = g.Coefficients.Estimate which gives beta =
1.0e+05 *
5.1879
0.0059
0.0004
But I don't really know how to store these numbers as functions, and it seems as though they've been rounded a bit..
Update: Nm I totally got it, beta(1), beta(2), beta(3).
Thanks much for your help!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!