You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: Exercise2.m
    path of file: ./repos/Matlab4CRE/practicals/2020-2021/practicals03/matlab
    
    the code of the file until where you have to start completion: %-------------------------------------------------------------------------%
%        ___  ___      _   _       _       ___ _____ ______ _____         |
%        |  \/  |     | | | |     | |     /   /  __ \| ___ \  ___|        |
%        | .  . | __ _| |_| | __ _| |__  / /| | /  \/| |_/ / |__          |
%        | |\/| |/ _` | __| |/ _` | '_ \/ /_| | |    |    /|  __|         |
%        | |  | | (_| | |_| | (_| | |_) \___  | \__/\| |\ \| |___         |
%        \_|  |_/\__,_|\__|_|\__,_|_.__/    |_/\____/\_| \_\____/         |
%                                                                         |
%                                          
    
function dY = PFR(z,Y)

    global A;       % [1/s]
    global Ea;      % [cal/mol]
    global P;       % [Pa]
    global S;       % [m2]
    global U;       % [kcal/m2/h/K]
    global D;       % [m]
    global deltaHR; % [cal/mol]
    global Cp;      % [cal/mol/K]
    global Fe;      % [kmol/h]
    global Cpe;     % [cal/mol/K]
    global Se;      % [m2]

    FA = Y(1);      % molar flow rate of A [kmol/h]
    FB = Y(2);      % molar flow rate of B [kmol/h]
    T  = Y(3);      % temperature [K]
    Te = Y(4);      % external temperature [K]
    
    Ctot = P/8314/T;                % [kmol/m3]
    k = A*exp(-Ea/1.987/T)*3600;    % [1/h];
    
    Ftot = FA+FB;                % [kmol/h]
    CA = Ctot*FA/Ftot;           % [kmol/m3]
    r = k*CA;                    % [kmol/m3/h]
    
    % Mass balance equations
    dFA = -S*r;                                     % [kmol/m/h]
    dFB =  S*r;                                     % [kmol/m/h]
    
    % Energy balance equation (kcal converted to cal, mol converted to kmol)
    dT  = -S*( (1000*U)*(T-Te)*4/D + r*(1000.*deltaHR)) / ....
                         (Ftot*(1000.*Cp));               % [K/m]
    dTe =  Se*( (1000.*U)*(T-Te)*4/D )/(Fe*(1000.*Cpe));  % [K/m]

    dY = [dFA dFB dT dTe]';

end