|
"Leo " <leoj_cruzz@hotmail.com> wrote in message <ib6vnn$dps$1@fred.mathworks.com>...
> "Leo " <leoj_cruzz@hotmail.com> wrote in message <ib6utf$ldq$1@fred.mathworks.com>...
> > Hi,
> >
> > I have the following equation:
> > i = a*(z - s*log(1 + z/s))*(1 + s/z)
> >
> > I want to assign numeric values to a, s, and i and find z (just as a hp calculator equation solver does).
> >
> > I can input the values, but i have problems on how to solve and find z.
> >
> > Furthermore, suppose there a a 100 values for each of the variables in excel spreadsheet. How can I substitute each value and obtain 100 values for z in the same spreadsheet?
> >
> > Thanks in advance
>
> Also i can't solve for z (i.e. z = f(a, s, i). If i could i could directly enter the equation for z in excel
Hi Leo,
If you like to solve the problem in Excel, You have to ask somewhere else, not here. Should you like to solve it in MATLAB, there are more possibilities.
You can use some function from Optimization Toolbox or my function LMFnlsq from FEX:
www.mathworks.com/matlabcentral/fileexchange/17534
For the solution, you have to write a function for evaluation residuals of the equation, say resid.m, that could have the following form:
function r = resid(p)
% RESID calculates a residual of an equation
a = p(1);
s = p(2);
i = p(3);
r = a*(z - s*log(1 + z/s))*(1 + s/z) - i;
The solution is found by calling
[p,ssq,cnt] = LMFnlsq(resid,p0,'Display',-1) % if you wish to see iterations
Parameter p0 is your estimate of the solution z.
All 100 solutions can be obtained in the for cycle after reading your data [a,s,i] at once from the Excel file by calling a function xlsread.
Hope it helps.
Mira
|