0

I am using the function fitnlm :

f= @(a,x)(a(1)*log(x+a(2))); mod= NonLinearModel.fit(A,B,f,[3,1])

for some data points (A,B)).

The output is
enter image description here

I am having a problem how to get separately the values of a(1) and a(2) to use them in an internal matlab function. Does anay one know how can I get them ?

Thank you for your help.

Nizar
  • 2,782
  • 3
    Upon calling NonLinearModel.fit, you get a NonLinearModel object out. What you want is probably one of the properties of this object. So look at the class documentation: https://www.mathworks.com/help/stats/nonlinearmodel-class.html It looks like what you want is (taking the variable names from your code excerpt) mod.Coefficients.Estimate. Note that this is really a programming question so that it is not really suitable for MSE. – Ian Dec 14 '16 at 15:43
  • Another useful page here. – Fabio Somenzi Dec 14 '16 at 15:46

1 Answers1

1

From the MATLAB documentation:

"Coefficient values, stored as a table. Coefficients has one row for each coefficient and the following columns" (as in the output of your model). "To obtain any of these columns as a vector, index into the property using dot notation."

Hence, in your example, the coefficients would be found in:

a = mod.Coefficients.Estimate

Giuseppe
  • 737