% LEP 10-3 : Hydrogenation of Ethylene to Ethane
%

PE=[1;1;1;3;5;0.5;0.5;0.5;0.5];%Independent variable
PEA=[1;1;1;1;1;1;0.5;3;5];%Independent variable
PH=[1;3;5;3;3;3;5;3;1];%Independent variable
RATE=[1.04;3.13;5.21;3.82;4.19;2.391;3.867;2.199;0.75];%Dependent variable
yo=[1;1;1];%Initial guess vector for k,KEA and KE
X=[PE PEA PH];
y1= nlinfit(X,RATE,@ODEfuna,yo);
y2= nlinfit(X,RATE,@ODEfunb,yo);
y3= nlinfit(X,RATE,@ODEfunc,yo);
y4= nlinfit(X,RATE,@ODEfund,yo);
warning('off','all')
k=y1(1);
KEA=y1(2);
KE=y1(3);
disp('The final values of k, KEA and KE for Model (a) are')
k
KEA
KE
k=y2(1);
KE=y2(2);
disp('The final values of k and KE for Model (b) are')
k
KE
k=y3(1);
KE=y3(2);
disp('The final values of k and KE for Model (c) are')
k
KE
k=y4(1);
a=y4(2);
b=y4(3);
disp('The final values of k, a and b for Model (d) are')
k
a
b



%

function RATE = ODEfuna(yo,X)
k=yo(1);
KEA=yo(2);
KE=yo(3);
RATE=k.*X(:,1).*X(:,3)./(1+KEA.*X(:,2)+KE.*X(:,1)); 
end
function RATE = ODEfunb(yo,X)
k=yo(1);
KE=yo(2);
RATE=k.*X(:,1).*X(:,3)./(1+KE.*X(:,1));
end
function RATE = ODEfunc(yo,X)
k=yo(1);
KE=yo(2);
RATE=k.*X(:,1).*X(:,3)./((1+KE.*X(:,1)).^2);
end
function RATE = ODEfund(yo,X)
k=yo(1);
a=yo(2);
b=yo(3);
RATE=k.*(X(:,1).^a).*(X(:,3)).^b;
end
