clear; n=100; %Sample size y=3+2*randn(n,1); %Generating the data phi_0=[1,2]; %Starting values for the optimization. Notice that they are far from the true values [phi,fval] = fminunc(@ll,phi_0,[],y); %Calling the function “ll”, with the starting values "phi_0"and data "y" as inputs. %This minimization procedure returns a vector "phi" which contains the estimates and a number "fval" which is the log-likelihood function evaluated at the estimates.