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: ft_spike_maketrials.m
    path of file: ./repos/fieldtrip/contrib/spike
    
    the code of the file until where you have to start completion: function [spike] = ft_spike_maketrials(cfg,spike)

% FT_SPIKE_MAKETRIALS converts raw timestamps in a SPIKE structure to spike times
% that are relative to an event trigger in an SPIKE structure. This is a
% preprocessing step to use functions such as FT_SPIKE_PSTH.
%
% The main function of FT_SPIKE_MAKETRIALS is to create the field spike.time and
% spike.trial, which contain the trial numbers in which the spikes were recorded, and
% the onset and offset of the trial relative to trigger time t = 0.
%
% Use as
%   [spike] = ft_spike_maketrials(cfg,spike)
% where the input data structure consists of raw spikes obtained from FT_READ_SPIKE

    
function [spike] = ft_spike_maketrials(cfg,spike)

% FT_SPIKE_MAKETRIALS converts raw timestamps in a SPIKE structure to spike times
% that are relative to an event trigger in an SPIKE structure. This is a
% preprocessing step to use functions such as FT_SPIKE_PSTH.
%
% The main function of FT_SPIKE_MAKETRIALS is to create the field spike.time and
% spike.trial, which contain the trial numbers in which the spikes were recorded, and
% the onset and offset of the trial relative to trigger time t = 0.
%
% Use as
%   [spike] = ft_spike_maketrials(cfg,spike)
% where the input data structure consists of raw spikes obtained from FT_READ_SPIKE
%
% Configurations:
%
%   cfg.trl = is an nTrials-by-M matrix, with at least 3 columns:
%     Every row contains start (col 1), end