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

답변 (1개)

Star Strider
Star Strider 2018년 3월 22일

0 개 추천

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.

카테고리

도움말 센터File Exchange에서 Interpolation에 대해 자세히 알아보기

태그

질문:

2018년 3월 22일

답변:

2018년 3월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by