Two-terms Exponential model

6 views (last 30 days)
Emiru
Emiru on 30 Jan 2016
Edited: Emiru on 24 Jan 2017
I need to use the polyfit command to determine the best exponential coefficients for the following two-terms equation:
y= a1 * exp(b1*x1^2+b2*x2^2+b3*x1*x2+b4*x1+b5*x2)
For the simplest situation (y= a* exp(kx)) I would proceed like this:
yeqn = @(coefs, x) coefs(1).*exp(coefs(2).*x);
xi = x;
eta = log(y);
P = polyfit(xi, eta, 1);
MyCoefs(1) = exp(P(2));
MyCoefs(2) = P(1)
is there any chance to do the same thing for my situation or should I use another approach?

Accepted Answer

John BG
John BG on 30 Jan 2016
you really need to define the window where you want to approximate the exponential function with a polynomial otherwise the same polynomial matching your exponential within a window fall behind throughout another because is left behind by the 'faster' growing capacity that exponentials have against polynomials, of any kind.
Having made clear the windowing point, instead of saying
.. need to use the polyfit command to determine the best exponential coefficients for the following 2nd order two-terms equation ..
try saying
.. need to use the polyfit ..to determine the best polynomial coefficients for the follwing equation ..
if it's the case you want to approximate an exponential with a polynomial, that is not made clear either, or the other way around.
So, please define first the function you want to approximate, and the kind of function you want to use to approximate the previous function.
And usually, the term 'second order' or generic 'n-th order' is usually applied to polynomials, not exponentials.
the polynomial order is precisely the last field of the polyfit( , , order) function. If as in your suggested script used order=1 it's like saying you want to approximate a reasonably complex function, your exponential, with either a constant or a straight line, and then there is no need for polyfit, just get the average within the window of interest, or the values of the functions on both tips of the window, and there you already have the line you are after.
John

More Answers (0)

Categories

Find more on Polynomials in Help Center and File Exchange

Tags

No tags entered yet.

Community Treasure Hunt

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

Start Hunting!