function fit_params=fit_image(f,init_params,X,Y,img, pLowBound, pUpperBound, options) %options = optimset('lsqnonlin'); %options.Display = 'iter'; %options.TolFun = tolerance; fit_params = lsqnonlin( ... @(p) Gaussian2D(p,X,Y) - img, ... init_params,pLowBound,pUpperBound,options ... );