|
"Robert " <robert.ashmore@yahoo.com> wrote in message <ggkhuq$1j1$1@fred.mathworks.com>...
SNIP
using the data and output the coefficients for an extended Antoine equation. I would like to code it straight in to VBasic so Excel does it automatically, but I could also build a .dll using Matlab and call it in a VBasic subroutine. Excel is the end program I am trying to build this tool in because not everyone uses Matlab. The extended equation form I am using is:
>
> ln(y)=e^(A+B/x+C*ln(x)+D*x+E*x^3)
SNIP
Hi Robert,
The above equation is a simpler form of extended Antoine equation which is more complicated, and has to be solved by a methods for nonlinear optimization using either Optimization Toolbox or some function from FEX, say LMFnlsq.
Fortunately, your form of the equation enables linearization. After aplying natural logarithm on both sides of the equation, we get (for z=log(y))
log(z) = A + B./x + C.*log(x) + D*x + E*x.^3;
It may be solved for unknown vector of linear combination constants A, B, C, D. The solution is
x = x(:);
c = [ones(size(x), 1./x, log(x), x, x.^3] \ log(z(:)) % where
c=[A; B; C; D];
It is necessary to say that the solution minimizes sum of squares of differences of logarthms, not of differences of left and right sides of the original equation. If the later be required, such obtained solution c would be good initial guess for a nonlinear solution.
Hope it helps.
Mira
|