function[f]=expfun(b,params) tvec = params.tvec; yvec = params.yvec; resid = yvec - feval(@expfun,b,tvec); f = resid'*resid;