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: pspm_convert_au2unit.m
    path of file: ./repos/PsPM/src
    
    the code of the file until where you have to start completion: function [sts, out] = pspm_convert_au2unit(varargin)
% ● Description
%   pspm_convert_au2unit converts arbitrary unit values to unit values. It
%   works on a PsPM file and is able to replace a channel or add the data as
%   a new channel.
% ● Features
%   Given arbitrary unit values are converted using a recording distance D
%   given in 'unit', a reference distance Dref given in 'reference_unit', a
%   multiplicator A given in 'reference_unit'.
%   Before applying the conversion, the function takes the square root of the
%   input data if the recording method is area. This is performed to always
%   return linear units.
%   Using the given variables, the following calculations are performed:
%   0. Take square root of data if recording is 'area'.
%   1. Let from unit to reference_unit converted recording distance be Dconv.
%   2. x ← A*(Dconv/Dref)*x
%   3. Convert x from ref_unit to unit.
% ● Format
%   [sts, channel_index] = pspm_convert_au2unit(fn, channel, unit, distance, multiplicator,
%                reference_distance, reference_unit, options)
%   [sts, converted_data] = pspm_convert_au2unit(data, unit, distance, record_method,
%                multiplicator, reference_distance, reference_unit, options)
% ● Arguments
%                 fn: filename which contains the channels to be converted
%               data: a one-dimensional vector which contains the data to be
%                     converted
%               channel: Channels which should be converted from area to diameter.
%                     This can be a channel number, any channel type including 
%                     'pupil' (which will select a channel according to the 
%                     precedence order specified in pspm_load_channel), or 'both',
%                     which will work on 'pupil_r' and 'pupil_l'. 
%                     Default is 'both'. 
%               unit: To which unit the data should be converted. possible
%                     values are mm, cm, dm, m, in, inches.
%           distance: distance between camera and eyes in units as specified in
%                     the parameter unit
%      record_method: either 'area' or 'diameter', tells the function what the
%                     format of the recorded data is
%      multiplicator: the multiplicator in the linear conversion.
% reference_distance: distance at which the multiplicator value was obtained,
%                     as specified in the parameter unit.
%                     The values will be proportionally translated to this
%                     distance before applying the conversion function.
%     reference_unit: reference unit with which the multiplicator and
%                     reference_distance values were obtained.
%                     Possible values are mm, cm, dm, m, in, inches
%           options:  a struct of optional settings
%   .channel_action:  ['add'/'replace'] Defines whether the new channel should
%                     be added or the previous outputs of this function should
%                     be replaced. (Default: 'add')
% ● History
%   Introduced in PsPM 3.1
%   Written in 2016 by Tobias Moser (University of Zurich)
%   Updated in 2024 by Dominik R Bach (University of Bonn)


    
function [sts, out] = pspm_convert_au2unit(varargin)
% ● Description
%   pspm_convert_au2unit converts arbitrary unit values to unit values. It
%   works on a PsPM file and is able to replace a channel or add the data as
%   a new channel.
% ● Features
%   Given arbitrary unit values are converted using a recording distance D
%   given in 'unit', a reference distance Dref given in 'reference_unit', a
%   multiplicator A given in 'reference_unit'.
%   Before applying the conversion, the function takes the square root of the
%   input data if the recording method is area. This is performed to always
%   return linear units.
%   Using the given variables, the following calculations are performed:
%   0. Take square root of data if recording is 'area'.
%   1. Let from unit to reference_unit converted recording distance be Dconv.
%   2. x ← A*(Dconv/Dref)*x
%   3. Convert x from ref_unit to unit.
% ● Format
%   [sts, channel_index] = pspm_convert_au2unit(fn, channel, unit, distance, multiplicator,
%                reference_distance, reference_unit, options)
%   [sts, converted_data] = pspm_convert_au2unit(data, unit, distance, record_method,
%                multiplicator, reference_distance, reference_unit, options)
% ● Arguments
%                 fn: filename which contains the channels to be converted
%               data: a one-dimensional vector which contains the data to be
%                     converted
%               channel: Channels which should be converted from area to diameter.
%                     This can be a channel number, any channel type including 
%                     'pupil' (which will select a channel according to the 
%                     precedence order specified in pspm_load_channel), or 'both',
%                     which will work on 'pupil_r' and 'pupil_l'. 
%                     Default is 'both'. 
%               unit: To which unit the data should be converted. possible
%                     values are mm, cm, dm, m, in, inches.
%           distance: distance between camera and eyes in units as specified in
%                     the parameter unit
%      record_method: either 'area' or 'diameter', tells the function what the
%                     format of the recorded data is
%      multiplicator: the multiplicator in the linear conversion.
% reference_distance: distance at which the multiplicator value was obtained,
%                     as specified in the parameter unit.
%                     The values will be proportionally translated to this
%                     distance before applying the conversion function.
%     reference_unit: reference unit with which the multiplicator and
%                     reference_distance values were obtained.
%                     Possible values are mm, cm, dm, m, in, inches
%           options:  a struct of optional settings
%   .channel_action:  ['add'/'replace'] Defines whether the new channel should
%                     be added or the previous outputs of this function should
%                     be replaced. (Default: 'add')
% ● History
%   Introduced in PsPM 3.1
%   Written in 2016 by Tobias Moser (University of Zurich)
%   Updated in 2024 by Dominik R Bach (University of Bonn)

%% initialise
global settings
if isempty(settings)
    pspm_init;
end