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: tightfig.m
    path of file: ./repos/osprey/libraries/tightfig
    
    the code of the file until where you have to start completion: function hfig = tightfig(hfig)
% tightfig
    
function [pos, ti] = colorbarpos (hcbar)

    % 1 point is 0.3528 mm
    
    pos = hcbar.Position;
    ti = [0,0,0,0];
    
    if ~isempty (strfind (hcbar.Location, 'outside'))

        if strcmp (hcbar.AxisLocation, 'out')
            
            tlabels = hcbar.TickLabels;
            
            fsize = hcbar.FontSize;
            
            switch hcbar.Location
                
                case 'northoutside'
                    
                    % make exta space a little more than the font size/height
                    ticklablespace_cm = 1.1 * (0.3528/10) * fsize;
                    
                    ti(4) = ti(4) + ticklablespace_cm;
                    
                case 'eastoutside'
                    
                    maxlabellen = max ( cellfun (@numel, tlabels, 'UniformOutput', true) );
            
                    % 0.62 factor is arbitrary and added because we don't
                    % know the width of every character in the label, the
                    % fsize refers to the height of the font
                    ticklablespace_cm = (0.3528/10) * fsize * maxlabellen * 0.62;

                    ti(3) = ti(3) + ticklablespace_cm;
                    
                case 'southoutside'
                    
                    % make exta space a little more than the font size/height
                    ticklablespace_cm = 1.1 * (0.3528/10) * fsize;

                    ti(2) = ti(2) + ticklablespace_cm;
                    
                case 'westoutside'
                    
                    maxlabellen = max ( cellfun (@numel, tlabels, 'UniformOutput', true) );
            
                    % 0.62 factor is arbitrary and added because we don't
                    % know the width of every character in the label, the
                    % fsize refers to the height of the font
                    ticklablespace_cm = (0.3528/10) * fsize * maxlabellen * 0.62;

                    ti(1) = ti(1) + ticklablespace_cm;
                    
            end