找了好久,记录一下:
[xData, yData] = prepareCurveData( yr, b );
% Set up fittype and options.
ft = fittype( 'poly1' );
% Fit model to data.
[g, gof] = fit( xData, yData, ft );
g就是下面的curvefit
>> curvefit
curvefit = Linear model Poly3: curvefit(x) = p1*x^3 + p2*x^2 + p3*x + p4 where x is normalized by mean 1890 and std 62.05 Coefficients (with 95% confidence bounds): p1 = 0.921 (-0.9743, 2.816) p2 = 25.18 (23.57, 26.79) p3 = 73.86 (70.33, 77.39) p4 = 61.74 (59.69, 63.8)
>> formula(curvefit)
ans = 'p1*x^3 + p2*x^2 + p3*x + p4'
>> coeffnames(curvefit)
ans = 4x1 cell {'p1'} {'p2'} {'p3'} {'p4'}
>> coeffvalues(curvefit)
ans = 1×4 0.9210 25.1834 73.8598 61.7444
>> confint(curvefit)
ans = 2×4 -0.9743 23.5736 70.3308 59.6907 2.8163 26.7931 77.3888 63.7981