How to fit parameters in an m.file to a curve?

1 visualización (últimos 30 días)
Felix
Felix el 7 de Ag. de 2012
To understand my problem it would be best if you run this m file:
https://dl.dropbox.com/u/368757/curve_fitting_problem.m
In the following I refer to the variable names in the file:
It will plot a measured_signal in blue to which I want to fit a function (modeled_signal, shown in red). This function is generated in the same file. However, it is not a simple one line equation (with which all curve fitting tutorials that I found are dealing). It is rather a convolution of two functions one of which is constant and the other contains some variables which I want to optimize.
How can I tell matlab to fit the "modeled_signal" to the "measured_signal" by changing the three variables in lines 9-11 (tmax, alpha, mag)?
Thank you very much for your help!

Respuesta aceptada

Seth DeLand
Seth DeLand el 7 de Ag. de 2012
Take a look at lsqcurvefit from the Optimization Toolbox. http://www.mathworks.com/help/toolbox/optim/ug/lsqcurvefit.html
You can write a function that takes in a vector with the parameter values and a vector with the xdata (t in your case), and then returns the values for the calculated modeled_signal. Then use lsqcurvefit to find the optimal parameters that fit your function to your ydata (measured_signal).
  1 comentario
Felix
Felix el 7 de Ag. de 2012
Thank you very much. It works now with this apporach. At first lsqcurvefit produced only complex numbers that made no sense, but this could be solved by setting reasonable boundaries for the solution.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Get Started with Curve Fitting Toolbox en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by