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: cat.m
    path of file: ./repos/mtex/geometry/@rotation
    
    the code of the file until where you have to start completion: function r = cat(dim,varargin)

    
function r = cat(dim,varargin)
% implement cat for rotation
%
% Syntax 
%   r = cat(dim,r1,r2,r3)
%
% Input
%  dim - dimension
%  r1, r2, r3 - @rotation
%
% Output
%  r - @rotation
%
% See also
% rotation/horzcat, rotation/vertcat

% remove emtpy arguments
varargin(cellfun('isempty',varargin)) = [];

% ensure result is at least rotation
r = varargin{1};
if ~isa(r,'rotation'), r = rotation(r);end