function[f,g,GN]=logistic(b,tvec,yvec) % f(X0,M,k,t) = M*X0*exp(kt) / ((M-X0)+X0*exp(kt)) (a) % = M*X0 / (X0+(M-X0)exp(-kt)) (b) % % f = .5*r'*r, where r is the residual % r = yvec - f(X0,M,k,tvec), % g = J'*r, % J = Jacobian of r (use (b) to compute) % GN = J'*J X0 = b(1); M = b(2); k = b(3); % residual r = % You fill in here. %Jacobian J = % You fill in here. % f,g,GN f = .5*r'*r; g = J'*r; GN = J'*J;