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: format_ticks.m
    path of file: ./repos/mpsim/lib/plot
    
    the code of the file until where you have to start completion: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% BEGIN HEADER
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Name: format_tick.m
%
%Usage: [hx,hy] = ...
%          format_tick(h,tickx,ticky,tickposx,tickposy,rotx,roty,offset,...
%                      varargin);
%
%Description: Replace or appends XTickLabels and YTickLabels of axis handle
%             h with input tickx and ticky array
%
%***NOTE!***: BE SURE TO DELETE ANY PREVIOUS TEXT OBJECTS CREATED BY THIS
%             FUNCTION BEFORE RUNNING THIS ON THE SAME FIGURE TWICE
%
%Required Inputs:
%       h        : handle of axis to change tick labels (can use gca)
%       tickx    : cell array of tick labels or string to append to current
%                  labels
%                  (Defaults to appending degree symbols if not inpu
    
function [hx,hy] = ...
    format_ticks(h,tickx,ticky,tickposx,tickposy,rotx,roty,offset,varargin)

%define axis text offset (percentage of total range)
if ~exist('offset','var');
    offset = 0.02;
elseif length(offset) == 0;
    offset = 0.02;
end;

%make sure the axis handle input really exists
if ~exist('h','var');
    h = gca;
    warning(['Axis handle NOT Input, Defaulting to Current Axes, '...
        num2str(h)]);
elseif length(h) == 0;
    h = gca;
    warning(['Axis Handle NOT Input, Defaulting to Current Axes, '...
        num2str(h)]);
elseif ~ishandle(h(1))
    warning(['Input (' num2str(h(1)) ') is NOT an axis handle, ' ...
        'defaulting to current axis, ' num2str(h)]);
        h = gca;
end;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%BEGIN: FIRST THE X-AXIS TICK LABELS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%fix the XTickLabels if they have been erased in the past
if length(get(h,'XTickLabel'))==0; 
    set(h,'XTickLabel',get(h,'XTick'));
end;
%set the xtick positions if entered
if exist('tickposx','var');
    if length(tickposx) > 0;
        set(h,'XTick',tickposx);
    end;
    tickposx = get(h,'XTick');
     set(h,'XTickLabel',tickposx);
end