Cos^2 fit for Malus Law.
Show older comments
Hello,
I am trying to fit some data with the following formula (Malus Law) :
I(theta)=I_0*cos^2(theta-theta_0)
where theta_0 is the value corresponding to the maximum of I (intensity).
I don't know how to fit my data with the formula given. Thank you for your help.
Here are my data for theta and I :
theta : 7.6 17.6 27.6 37.6 47.6 57.6 67.6 77.6 87.6 97.6 107.6 117.6 127.6 137.6 147.6 157.6 167.6 177.6 187.6 197.6 207.6 217.6 227.6 237.6 247.6 257.6 267.6 277.6 287.6 297.6 307.6 317.6 327.6 337.6 347.6 357.6
I: 3.001 2.206 1.391 0.59 0.254 0.03 0.053 0.456 1.125 1.85 2.681 3.523 4.161 4.628 4.855 4.805 4.428 3.823 2.901 2.24 1.257 0.673 0.224 0.011 0.101 0.475 1.096 1.868 2.734 3.516 4.224 4.66 4.855 4.773 4.351 3.77
Answers (1)
Torsten
on 10 Dec 2014
0 votes
xdata = ... [7.6 17.6 27.6 37.6 47.6 57.6 67.6 77.6 87.6 97.6 107.6 117.6 127.6 137.6 147.6 157.6 167.6 177.6 187.6 197.6 207.6 217.6 227.6 237.6 247.6 257.6 267.6 277.6 287.6 297.6 307.6 317.6 327.6 337.6 347.6 357.6];
ydata = ... [3.001 2.206 1.391 0.59 0.254 0.03 0.053 0.456 1.125 1.85 2.681 3.523 4.161 4.628 4.855 4.805 4.428 3.823 2.901 2.24 1.257 0.673 0.224 0.011 0.101 0.475 1.096 1.868 2.734 3.516 4.224 4.66 4.855 4.773 4.351 3.77];
x0 = [1; 1] % Starting guess
myfun=@(x,xdata)(x(1)*(cosd(xdata-x(2))).^2;
[x,resnorm] = lsqcurvefit(@myfun,x0,xdata,ydata);
Best wishes
Torsten.
1 Comment
Torsten
on 10 Dec 2014
Should read:
myfun=@(x,xdata)(x(1)*(cosd(xdata-x(2)).^2);
[x,resnorm] = lsqcurvefit(myfun,x0,xdata,ydata);
Best wishes
Torsten.
Categories
Find more on MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!