From: Hu Qing on
Dear MATLAB User Community!

I have a problem with nonlinear least squares fit.
I have a series data (xi,yi) i = 1,2,3,...n
plot (x, y)
xlabel ('distance[m]')
ylabel ('level [m]')
legend ('profile')

and I want to fit it to this equation:

F1(x) = -A*(x+xs)^p

Three parameters A, p, xs are defined by fitting values.

how can i do this?

Thank you very much!
From: Marcus M. Edvall on
You can solve it with tomSym using the following code:

n = 300;
x = rand(n,1);
y = rand(n,1);
toms A xs p
sol = ezsolve(y+A*(x+xs).^p);

There are probably quite a bit of options.

Best wishes, Marcus
http://tomopt.com/
http://tomsym.com/

From: Alan Weiss on
On 5/11/2010 7:04 PM, Hu Qing wrote:
> Dear MATLAB User Community!
>
> I have a problem with nonlinear least squares fit.
> I have a series data (xi,yi) i = 1,2,3,...n
> plot (x, y)
> xlabel ('distance[m]')
> ylabel ('level [m]')
> legend ('profile')
>
> and I want to fit it to this equation:
>
> F1(x) = -A*(x+xs)^p
> Three parameters A, p, xs are defined by fitting values.
>
> how can i do this?
>
> Thank you very much!

Take a look at lsqcurvefit. Example:
http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/brn4noo.html#brp3l6v-1

Function reference page:
http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/lsqcurvefit.html

Alan Weiss
MATLAB mathematical toolbox documentation
From: Frederic Moisy on
"Hu Qing" <bluerivers(a)live.com> wrote in message <hscnp6$kt3$1(a)fred.mathworks.com>...
> Dear MATLAB User Community!
>
> I have a problem with nonlinear least squares fit.
> I have a series data (xi,yi) i = 1,2,3,...n
> plot (x, y)
> xlabel ('distance[m]')
> ylabel ('level [m]')
> legend ('profile')
>
> and I want to fit it to this equation:
>
> F1(x) = -A*(x+xs)^p
>
> Three parameters A, p, xs are defined by fitting values.
>
> how can i do this?
>
> Thank you very much!

You can also have a look to the Ezyfit toolbox:
http://www.mathworks.com/matlabcentral/fileexchange/10176-ezyfit-2-30

plot(x,y)
showfit('F1(x) = -A*(x+xs)^p ');
From: Hu Qing on
"Marcus M. Edvall" <edvall(a)gmail.com> wrote in message <2b5bdccc-99d5-4bc3-aae9-3378192252a6(a)37g2000yqm.googlegroups.com>...
> You can solve it with tomSym using the following code:
>
> n = 300;
> x = rand(n,1);
> y = rand(n,1);
> toms A xs p
> sol = ezsolve(y+A*(x+xs).^p);
>
> There are probably quite a bit of options.
>
> Best wishes, Marcus
> http://tomopt.com/
> http://tomsym.com/
Dear Marcus

That's great! Thanks for help.

Best wishes, HuQing