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_write_channel.m
    path of file: ./repos/PsPM/src
    
    the code of the file until where you have to start completion: function [sts, infos] = pspm_write_channel(fn, newdata, channel_action, options)
% ● Description
%   pspm_write_channel adds, replaces and deletes channels in an existing
%   data file. This function is an integration of the former functions
%   pspm_add_channel and pspm_rewrite_channel.
% ● Format
%   [sts, infos] = pspm_write_channel(fn, newdata, channel_action, options)

    
function [sts, infos] = pspm_write_channel(fn, newdata, channel_action, options)
% ● Description
%   pspm_write_channel adds, replaces and deletes channels in an existing
%   data file. This function is an integration of the former functions
%   pspm_add_channel and pspm_rewrite_channel.
% ● Format
%   [sts, infos] = pspm_write_channel(fn, newdata, channel_action, options)
% ● Arguments
%               fn: data file name
%          newdata: [struct()/empty] is either a new data struct or a cell
%                   array of new data structs.
%   channel_action: accepts 'add'/'replace'/'delete'
%                   'add':  add newdata as a new channel
%                   'replace':  replace channel with given newdata
%                   'delete': remove channel given with options.channel
%    ┌─────options:
%    ├────────.msg: custom history message [char/struct()]
%    ├─────.prefix: custom history message prefix text, but automatically added
%    │              action verb (only prefix defined). The text will be
%    │              <prefix> <action>ed on <date>
%    ├────.channel: specify which channel should be 'edited'
%    │              default value is 0
%    └─────.delete: method to look for a channel when options.channel is not an
%                   integer, accepts 'last'/'first'/'all'.
%                   'last':   (default) deletes last occurence of the given
%                             channeltype
%                   'first':  deletes the first occurence
%                   'all':    removes all occurences
% ● Outputs
%              sts:
%    ┌──────.infos: Outputs will be written into the .info struct.
%    │              The structure depend