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
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 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!