how to set nlinfit parameters ?J
Show older comments
Hello
I would need some help for fitting my data. Let's assume that I want to fit data registred in the matrix "spe":
x=spe(N,1)
y=spe(N,2)
and that it should be fitted by a Gaussian function
I have defined the matlab function for the Gaussian :
function fun = gauss(b1,b2,b3,x)
fun = b3 * (1/(b1*sqrt(2*pi))) * exp(-(x-b2).^2/(2*(b1).^2));
end
and then, I want to use this function to fit my spe data using this expression in my main program using the nlinfit function.
As far as I understood, I have to create a function handle, which, by the way I am not understanding exactly what it is, in order to use nlinfit :
I tried :
mdl = @gauss
b0 = [1 1480 500];
b = nlinfit(spe(:,1), spe(:,2), mdlgausstest,b0);
but it is returning some error message.
Could you help me? Thank you very much !!
Accepted Answer
More Answers (1)
Categories
Find more on Nonlinear Regression in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!