12.07.2015 Views

What Is Optimization Toolbox?

What Is Optimization Toolbox?

What Is Optimization Toolbox?

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

lsqcurvefitLevenbergMarquardt Choose Levenberg-Marquardt overGauss-Newton algorithm.LineSearchTypeLine search algorithm choice.ExamplesGiven vectors of data xdata and ydata, supposeyouwanttofindcoefficients x to find the best fit to the exponential decay equationydata() i = x( 1) * e( x( 2)* xdata( i))That is, you want to minimizewhere m is the length of xdata and ydata, the function F is defined byF(x,xdata) = x(1)*exp(x(2)*xdata);and the starting point is x0 = [100; -1];.First,writeanM-filetoreturnthevalueofF (F has n components).function F = myfun(x,xdata)F = x(1)*exp(x(2)*xdata);Next, invoke an optimization routine:% Assume you determined xdata and ydata experimentallyxdata = ...[0.9 1.5 13.8 19.8 24.1 28.2 35.2 60.3 74.6 81.3];ydata = ...[455.2 428.6 124.1 67.3 43.2 28.1 13.1 -0.4 -1.3 -1.5];x0 = [100; -1] % Starting guess[x,resnorm] = lsqcurvefit(@myfun,x0,xdata,ydata)8-150

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!