Exponential curve fit matlab

后端 未结 2 1931
走了就别回头了
走了就别回头了 2021-01-15 18:38

I have the following equation:

\"\"

I want to do a exponenti

相关标签:
2条回答
  • 2021-01-15 18:52

    Building on what @eigenchris said, simply take the natural logarithm (log in MATLAB) of both sides of the equation. If we do this, we would in fact be linearizing the equation in log space. In other words, given your original equation:

    We get:

    However, this isn't exactly polynomial regression. This is more of a least squares fitting of your points. Specifically, what you would do is given a set of y and set pair of (u,a) points, you would build a system of equations and solve for this system via least squares. In other words, given the set y = (y_0, y_1, y_2,...y_N), and (u,a) = ((u_0, a_0), (u_1, a_1), ..., (u_N, a_N)), where N is the number of points that you have, you would build your system of equations like so:

    This can be written in matrix form:

    To solve for A and B, you simply need to find the least-squares solution. You can see that it's in the form of:

    Y = AX
    

    To solve for X, we use what is called the pseudoinverse. As such:

    X = A^{*} * Y
    

    A^{*} is the pseudoinverse. This can eloquently be done in MATLAB using the \ or mldivide operator. All you have to do is build a vector of y values with the log taken, as well as building the matrix of u and a values. Therefore, if your points (u,a) are stored in U and A respectively, as well as the values of y stored in Y, you would simply do this:

    x = [u.^2 a.^3] \ log(y);
    

    x(1) will contain the coefficient for A, while x(2) will contain the coefficient for B. As A. Donda has noted in his answer (which I embarrassingly forgot about), the values of A and B are obtained assuming that the errors with respect to the exact curve you are trying to fit to are normally (Gaussian) distributed with a constant variance. The errors also need to be additive. If this is not the case, then your parameters achieved may not represent the best fit possible.

    See this Wikipedia page for more details on what assumptions least-squares fitting takes:

    http://en.wikipedia.org/wiki/Least_squares#Least_squares.2C_regression_analysis_and_statistics

    0 讨论(0)
  • 2021-01-15 18:57

    One approach is to use a linear regression of log(y) with respect to u² and a³:

    Assuming that u, a, and y are column vectors of the same length:

    AB = [u .^ 2, a .^ 3] \ log(y)
    

    After this, AB(1) is the fit value for A and AB(2) is the fit value for B. The computation uses Matlab's mldivide operator; an alternative would be to use the pseudo-inverse.

    The fit values found this way are Maximum Likelihood estimates of the parameters under the assumption that deviations from the exact equation are constant-variance normally distributed errors additive to A u² + B a³. If the actual source of deviations differs from this, these estimates may not be optimal.

    0 讨论(0)
提交回复
热议问题