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: CTDI.m
    path of file: ./repos/TIGRE/MATLAB/Utilities/IO/VarianCBCT
    
    the code of the file until where you have to start completion: function CTDI = CTDI(datafolder)
% Calculate CT Dosimetry Index (cGy) of a CBCT scan 
% CTDI = DoseFactor * (mAs/100) * Num_Projection 

    
function CTDI = CTDI(datafolder)
% Calculate CT Dosimetry Index (cGy) of a CBCT scan 
% CTDI = DoseFactor * (mAs/100) * Num_Projection 
% Reference: TrueBeam Technical Reference Guide II: Imaging
% Date: 2021-11-23
% Author: Yi Du
% Email: yi.du@hotmail.com

% Load ScanXML
if(~exist('ScanXML', 'var'))
    % Read ScanXML
    filestr = dir([datafolder filesep 'Scan.xml']);
    ScanXML = getfield(xml2struct(fullfile(filestr.folder, filestr.name)), 'Scan');
end