If you have Optimization Toolbox, take a look at lsqcurvefit:
http://www.mathworks.com/help/toolbox/optim/ug/brn4noo.html#brp3l6v1
If you have Statistics Toolbox, take a look at nlinfit:
http://www.mathworks.com/help/toolbox/stats/bq_676m43.html#bq_676m44
By saying
c = A \ b % solution of the minimization problem
you are assuming that the regression is linear. But it obviously is not.
You need a nonlinear model.
In your MATLAB code you also need to use ./ instead of / for division of
vectors.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
On 7/6/2011 12:46 PM, Alex wrote:
> I have the following equation that i want to find the parameters c1, c2
> and c3.
>
> E = SUM(yj(1/(c1*c2))*(c3asinh(sinh(c3)*exp(c1*j*2*pi))))^2
>
> yj is consecutive timings for a tennis ball, on a string revolving
> around a pole (the ball cannot change height)
>
> I have found some help with this:
>
> x = [ 1,2,3,4,5 ];
>
> y = [ 2.2, 1.9, 1.7, 1.5, 1.4];
>
> a11 = sum(x.^2); a12 = sum(x); a21 = sum(x); a22 = sum(ones(1,length(x)));
>
> A = [ a11,a12; a21,a22] % the coefficient matrix of the minimization
> problem
> c1 = 1;
> c2 = 1;
> c3 = 1;
> diff_c1 =
> (c3asinh(exp(2*pi*x.*c1).*sinh(c3)))/(c1^2*c2)+(2*x.*pi*exp(2*c1*x.*pi).*sinh(c3)*asinh(exp(2*c1*x.*pi).*sinh(c3)))/(c1*c2)
>
> diff_c2 = (c3asinh(exp(2*c1*x.*pi).*sinh(c3)))/(c1*c2^2)
> diff_c3 =
> (exp(2*c1*x.*pi).*cosh(c2)*asinh(exp(2*c1*x.*pi).*sinh(c3))1)/(c1*c2)
> b1 = sum(diff_c1*y); b2 = sum(diff_c2*y); b3 = sum(diff_c3*y);
>
> b = [ b1; b2; b3 ] % righthandside of the minimization problem
>
> c = A \ b % solution of the minimization problem
>
> xApr = 0 : 0.001 : 1; yApr = c(1)*xApr + c(2);
>
> plot(x,y,'*g',xApr,yApr,'b');
> Basically diff_c1,c2,c3 are the parts multiplied by the data values yj
> for least squares minimization, i think this is correct. b1,2,3 are
> these multiples.
>
> I think the problem is I haven't got my '.''s in the correct place. I
> know that they are required to say do this for all x and y's but Im not
> sure exactly where they are required.
>
> I have posted this here because I would also appreciate some help as to
> whether I am doing this the correct way  because I also require initial
> values of c1,2,3 which i have stated as 1 but again I am not sure if I
> have done that correctly
