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: calculateSingleChi2.m
    path of file: ./repos/d2d/arFramework3/ThirdParty/strike-goldd/STRIKE-GOLDD/MEIGO64/MEIGO/PEtabMEIGO/meigo
    
    the code of the file until where you have to start completion: function out = calculateSingleChi2(measurement, simulation, noise_value, scale)
    %Calculates single chi2 as:
    %
    %          chi2_i = (simulation_i - measure_i)^2 / noise_value
    %
    %Arguments:
    %   measurement numeric:
    %       Observable measurement unscaled.
    %   simulation numeric:
    %       Observable simulation unscaled.
    %   noise_value numeric:
    %       Observable noise value.

    
function out = calculateSingleChi2(measurement, simulation, noise_value, scale)
    %Calculates single chi2 as:
    %
    %          chi2_i = (simulation_i - measure_i)^2 / noise_value
    %
    %Arguments:
    %   measurement numeric:
    %       Observable measurement unscaled.
    %   simulation numeric:
    %       Observable simulation unscaled.
    %   noise_value numeric:
    %       Observable noise value.
    %   scale string:
    %       Observable scale, "lin", "log" or "log10".
    %
    %Returns:
    %   numeric
    %       Single chi2.
    
    if strcmp(scale, 'lin')
        out = ((simulation - measurement)/noise_value)^2;
    elseif strcmp(scale, 'log')
        out = ((log(simulation) - log(measurement))/noise_value)^2;
    elseif strcmp(scale, 'log10')
        out = ((log10(simulation) - log10(measurement))/noise_value)^2;
    end