fminsearch Usage Question for function with 3 inputs

I am writing code to find the best fit of a sine function to NMR spectra. There are several superimposed sine functions from noise in the data (called the FID).
I have a function called fitFun that takes in the initial guess (IG), frequency (nu), and latest FID, and returns the coefficients (b,d,c) of the best fit for the function: b*sin(2*pi*(nu+d)+c). I want it to hold FID and frequency constant, and return only the best fit initial guess.
When I tried calling fminsearch(@fitFun,[IG,nu,FID]), I get horizcat error, and vertcat error for using ;.
Is there a better way to do this? Is fminsearch an appropriate function to call for this?
Thanks

Respuestas (1)

Star Strider
Star Strider el 22 de Mzo. de 2018
See if the solution in Curve fitting to a sinusoidal function (link) works for you. It is essentially what you are doing. You can tweak the code to do what you want.

Categorías

Etiquetas

Preguntada:

el 22 de Mzo. de 2018

Respondida:

el 22 de Mzo. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by