Non- Linear curve fitting
Show older comments
I have a set of data and I need to fit it to the curve F(x,xdata) and then find the values of five unknown coefficients .
a,b,c,d and e are the five coefficients which are replaced by x(0) , x(1) , x(2), x(3), x(4) and x(5) in the code below.
Running this code produces an error message. But when I removed "xdata" which was originally multiplied to the sqaured expression in the later part of the function, I got an output containing the values of the coefficients I needed.
How do i get an ouput while not having to remove "xdata" from the later part of the function?
clc;
Data = ...
[-0.02 2000
0 1650
0.03 1300
0.06 1050
0.09 880
0.12 700
0.15 550
0.18 400
0.21 240
0.24 120
0.27 0 ];
k = Data(:,1);
y = Data(:,2);
F = @(x,xdata)6*(x(1)*exp(-xdata*x(2))-x(3))*(2*(1-xdata*(x(4)*exp(-100000)-x(5)))^2-1);
plot(k,y,'r');
x0 = [1 1 1 1 1];
[x] = lsqcurvefit(F,x0,k,y)
Accepted Answer
More Answers (0)
Categories
Find more on Get Started with Curve Fitting Toolbox in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!