% step1.m 
% 
clear all

global alpha beta gamma delta Xbar Ubar u0 A B; 

clf % clear figure

% read given data
data

% fit the rate function to measured data 
xmin=fmins('fel',[1 1]);
delta=xmin(1)
gamma=xmin(2)

clf
plot(temp,rate,'ro')
hold
fplot('arrhen',[temp(1),temp(7)])

% compute constants 
alpha=-DeltaH*cf/(rho*cp*Tf)
Xbar=zeros(2,1);        % create a column vector
Xbar(1)=0.5;
delta1=delta*Xbar(1)/(1-Xbar(1));
Xbar(2)=1-log(delta1)/(gamma+log(delta1));
Xbar

R=8.3143                 % [J/(mol K)]   the gas constant 
k0=delta*exp(gamma)/tau  % [s^-1]        the Arrhenius rate constant
E=gamma*R*Tf             % [J/mol]       the activation energy 

% define default values for step3 and step4
% these should be changed when you run step3 and step4

x0 = [0.01;0.01], t1=10, u0=0, beta=1 
