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: progressbar.m
    path of file: ./repos/doa-tools/utils
    
    the code of the file until where you have to start completion: function progressbar(option, varargin)
%PROGRESSBAR Prints a progress bar.
%Syntax:

    
function progressbar(option, varargin)
%PROGRESSBAR Prints a progress bar.
%Syntax:
%   PROGRESSBAR('reset', total_progress)
%   PROGRESSBAR('resettimer')
%   PROGRESSBAR('advance'[, step])
%   PROGRESSBAR('end')
%   PROGRESSBAR('barwidth', bar_width)
%   PROGRESSBAR('displaymode', mode)
%   PROGRESSBAR('minimalupdateinterval', min_interval);

persistent total_progress;
persistent current_progress;
persistent last_text_width;
persistent start_time;
persistent total_time;
persistent bar_width;
persistent display_mode;
persistent min_interval;
persistent last_print_time;

if isempty(total_progress)
    total_progress = 0;
    current_progress = 0;
    last_text_width = 0;
    bar_width = 20;
    display_mode = 0;
    min_interval = 0.3;
end

switch lower(option)
    case 'minimalupdateinterval'
        min_interval = max(double(varargin{1}), 0);
    case 'displaymode'
        if nargin == 2
            switch lower(varargin{1})
                case 'replace'
                    display_mode = 0;
                case 'append