How do fit a custom model to my data?
2 views (last 30 days)
Show older comments
I have the following equation: I(theta)=I_0*(cos(beta))^2*(sin(alpha))^2 where: beta=(pi*d/lambda)*sin(theta) alpha=(pi*a/lambda)*sin(theta) I am supposed to fit this function to several sets of data for a nonlinear fit and obtain the values of the constants "a" and "d". I have tried using the line fit application from matlab but I do not get what I want. I am trying to constraint the coefficients to an estimate of what they are supposed to be, but the R-square just becomes worse. This is my data: "xdata = [-0.0050,-0.0045,-0.0040,-0.0035,-0.0030,-0.0025,-0.0020,... -0.00150,-0.0010,-0.0005,0.0001,0.00050,0.0010,0.0015,0.0020,... 0.0025,0.0030,0.00350,0.0040,0.0045,0.0050]; ydata = [1.53,2.36,2.0,2.43,1.56,2.50,2.23,3.03,2.23,2.96,6.26,4.86,... 2.20,4.63,4.83,2.60,2.86,3.13,2.36,2.70,2.73];" Are there any other ways in which I can do this, is there a specific script I can use to fit the function showed above for which I could get a good R-square with close coefficients? I would be most thankful if you could take me through the process with detailed explanations, I am very new at matlab.
2 Comments
José-Luis
on 19 Mar 2014
It might mean that your function is not suited to fit your data. Impossible to say without looking at it.
Answers (0)
See Also
Categories
Find more on Get Started with Curve Fitting Toolbox 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!