From: PRITAM on
Hello Everybody,
I am having a hard time fitting a user-defined function to a set of data.I have two columns of data namely 'x' and 'y' (all contained in two columns of a Excel spread sheet) and I have an equation reading y=f(x) containing 'n' number of parameters. I would like to fit the function to the 'graph' drawn by "plot (x,y,'o'). I there are errors creeping in.

My function is : y = 0.25*(cosd(B)).^2*(k*h).^2*((cosd(A)/(cosd(B)).^2)*(-(C+(C*E*(sind(t)).^2.*(cosd(x)).^2)/(C+E*(cosd(t)).^2))*(cosd(B)).^2+1-((sind(B)).^2)/(C+E*(cosd(t)).^2))+(sind(A)*2*E*sind(t).*sind(x))./(C+E*(cosd(t)).^2).*(cosd(t).*sind(B)+C.*sind(t).*cosd(x).*cosd(B))).^2;

where the initial guess for the parameters are as follows:

A=1(in degree)
B=53.6 (in degree)
C=2.26
E=.18
h=18e-9
w=668w-9
k=(2*pi)/w
t=90 (in degree)

I was using " showfit (' y=..............') " and f=(x,y,'y=.......',[ initial guess])' to fit the function to the "x-y"=graph and eventually I was expecting to extract the best-fit values for the parameters.

Can someone please help me out? Thanks in advance.

Pritam