lsqcurvefit change between matlab 2007b and 2010b(SP1)?
Show older comments
Hi everybody,
I recently updated my Matlab from 2007b to 2010b(SP1). I had a code written previously to fit Gaussians and or Double Gaussians to my data set using the lsqcurvefit command, and it seemed to work well. When I run the same code in the 2010b(SP1) version, the fit parameters come out differently. Is there a difference in lsqcurvefit between the two versions? Is it possible that I changed some default setting in the 2007b version without realizing it? If so, is there a way to check what all your settings are for a specific command?
I also have the curve fitting toolbox with the 2010b(SP1) version, and the fit looks the same as the fit I coded when it runs in 2010b(SP1), but different from the fit I coded when I run the script in 2007b.
Here is an example that comes out differently in the two versions:
xdata=[0;7.8;15.2;22.3;29.1;35.7;41.9;48.0;53.8;59.4;64.8;70.1;...
75.2;80.1;84.9;89.5;94.0;98.4;102.6;106.8;110.9];
ydata=[0;0;0.0676;0.225;0.360;0.180;0.097;0.022;0.030;0.007;...
0;0.007;0;0;0;0;0;0;0;0;0;];
xdist = 0:0.01:110;
startingVals = [0.3 32.18 7 0.05 51.68 8];
[newParam,resnorm,residual] = lsqcurvefit(@DoubleGauss, startingVals, xdata, ydata);
y=DoubleGauss(newParam,xdist);
figure
scatter(xdata,ydata,'ko','filled');
hold on
plot(xdist,y,'k');
also, my function for the Double Gaussian is defined as:
function F = DoubleGauss(x,xdata)
F = (x(1) .* exp( -(xdata-x(2)).^2 ./ (2.*x(3).^2) ))+(x(4) .* exp( -(xdata-x(5)).^2 ./ (2.*x(6).^2) ));
Any help would be much appreciated. Thanks!
Corinne
Answers (1)
zul karnaen
on 4 Apr 2011
0 votes
u can write in command window your data x and y >>xdata=[0;7.8;15.2;22.3;29.1;35.7;41.9;48.0;53.8;59.4;64.8;70.1;... 75.2;80.1;84.9;89.5;94.0;98.4;102.6;106.8;110.9]; >>ydata=[0;0;0.0676;0.225;0.360;0.180;0.097;0.022;0.030;0.007;... 0;0.007;0;0;0;0;0;0;0;0;0;]; and write command >>cftool and click data->in x data choose xdata, y data choose ydata,And click create data set and go to fitted,click fitting, click new fit, in type of fit choose custom equations,and then click new insert your function,and choose your iteration, and click apply.
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!