How do I use the Levenberg-Marquardt Algorithm - New to MATLAB

9 views (last 30 days)
From a pre-existing MathWorks post, the function is as follows
[x,ssq,cnt] = LMFsolve(Equations,X0);
  • Equations is a function name (string) or a handle defining a set of equations,
  • X0 is vector of initial estimates of solutions,
  • x is the least-squares solution,
  • ssq is sum of squares of equation residuals,
  • cnt is a number of iterations
What I'm doing: I have some data of a compton curve (detected radiation form a sample). It's set up as x=channel number and y=number of counts. I have no problems importing the data to MATLAB. It looks more or less like a gaussian (normal) curve, but a bit asymmetrical. I have a test function made by someone before me, and I'm testing the accuracy of it. I need to input the test function and the data into LMF and minimize the parameters of the test function. Any insight as to how to do this would be amazing. I've made a function file for a simple test function DGauss
function [DGy] = DGauss(x,H1,C1,S1)
DGauss=H1*exp(-(x-C1).^2/(2*S1^2))
end
just a gaussian function to make sure I'm doing this right. H1 is the height, C1 is the centre position, S1 is the standard deviation (the width) of the normal curve.
I'm having problems figuring out the syntax. This is my first time using MATLAB so extensively. Where do I incorporate the function file, and where do I incorporate the data? Thanks!!

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!