function Example6A clear, clc, format short g, format compact xguess = [0.1 0.1 0.1]; % initial guess vector disp('Variable values at the initial estimate'); fguess=MNLEfun(xguess); disp(' Variable Value Function Value') for i=1:size(xguess,2); disp([' x' int2str(i) ' ' num2str(xguess(i)) ' ' num2str(fguess(i))]); end options = optimset('Diagnostics',['off'],'TolFun',[1e-9],'TolX',[1e-9]); xsolv=fsolve(@MNLEfun,xguess,options); disp('Variable values at the solution'); fsolv=MNLEfun(xsolv); disp(' Variable Value Function Value') for i=1:size(xguess,2); disp([' x' int2str(i) ' ' num2str(xsolv(i)) ' ' num2str(fsolv(i))]) end %- - - - - - - - - - - - - - - - - - - - - - function fx = MNLEfun(x); CD = x(1); CX = x(2); CZ = x(3); T = 370; KC1 = 1 / exp(-2396.301 * (1 / 330 - (1 / T))) * .7; KC2 = 1 / exp(2421.518 * (1 / 330 - (1 / T))) * 4; KC3 = 1 / exp(-8954.7 * (1 / 330 - (1 / T))) * 1 * T / 330; CY = CX + CZ; CA0 = 1.5; CB0 = 1.5; CC = CD - CY; CA = CA0 - CD - CZ; CB = CB0 - CD - CY; fx(1,1) = CC * CD - (KC1 * CA * CB); fx(2,1) = CX * CY - (KC2 * CB * CC); fx(3,1) = CZ - (KC3 * CA * CX);