Current location - Education and Training Encyclopedia - Graduation thesis - Matlab Gaussian fitting
Matlab Gaussian fitting
Create a new function using the following code:

function [fitresult,gof] = createFit(x,y)

[xData,yData] = prepareCurveData( x,y); % set fittype and options.

ft = fittype(' gauss 1 ');

Opts = fitoptions( 'Method',' nonlinear least square');

opts。 Display = ' Off

opts。 lower =[-Inf-Inf 0];

opts。 start point =[y(ceil(length(x)/2))x(ceil(length(x)/2))0. 1]; % make the model conform to the data.

[fitresult,gof] = fit( xData,yData,ft,opts); Percentage of drawings that match the data.

h = plot( fitresult,xData,y data);

xlabel('β');

y label(' R ');

Legend off

Grid open; Hold on;

plot(fitresult.b 1,fitresult.a 1,'^','markersize',6)

Run it, and then enter: createFit(x, y) in the command line window.