On Friday, May 2, 2014 11:10:10 AM UTC+12, John D'Errico wrote: > "Baha " <firstname.lastname@example.org> wrote in message <email@example.com>... > > > Hi, > > > > > > I am trying to do line-fitting by using a tanh and natural log equation. Here is the equation: > > > D = (a+b)/2 - (a-b)/2*tanh[d*ln(X/c)]; > > > variable: X; Data points: D(X); constants: a, b, c, d > > > Data points and corresponding variable can be simply > > > D(X) = [0.75 0.72 0.70 0.67 0.63 0.58 0.55]; > > > X = [0.01 0.02 0.03 0.04 0.05 0.08 0.10]; > > > I am looking for getting a,b,c,d constants that will give me almost exact values of D at the sample points. I tried to transform the tanh equation above to a polynomial form but I couldn't get it there. I would be so thankful if anyone can help me to do this line-fit? > > > > > > I tried to use least square line fit but I am not happy with this minimization results because it doesn't give exact results of D at sample points X. So, I am more into finding a,b,c,d values that will give me exact values of D at the sample points X. Here I am copying lsqcurvefit results for your information and this may help some others. > > > > > > D = [0.75 0.72 0.70 0.67 0.63 0.58 0.55]'; > > > X = [0.01 0.02 0.03 0.04 0.05 0.08 0.10]'; a0 = [2;2;2;2]; Len = length(D); > > > predicted = @(a,X) (a(1)+a(2))/2*ones(Len,1)-(a(1)-a(2))/2*tanh(a(4)*log(X./a(3))); > > > [ahat,resnorm,residual,exitflag,output,lambda,jacobian] = lsqcurvefit(predicted,a0,X,D); > > > a = ahat(1); b = ahat(2); c = ahat(3); d = ahat(4); > > > > > > I am looking forward to seeing your suggestions. > > > Baha > > > > Be serious. Why in the name of god and little green apples > > do you expect an almost exact fit to these values? > > > > Sorry, but that is insane. > > > > Wanting the impossible will not make it happen. > > > > John
Are you saying, John, that I will NEVER find a Matlab routine that spins straw into gold?