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_write_cifti.m
    path of file: ./repos/spm12/external/fieldtrip/fileio
    
    the code of the file until where you have to start completion: function ft_write_cifti(filename, source, varargin)

% FT_WRITE_CIFTI writes functional data or functional co
    
function s = printwithspace(x)
x = x(:)'; % convert to vector
if all(round(x)==x)
  % print as integer value
  s = sprintf('%d ', x);
else
  % print as floating point value
  s = sprintf('%f ', x);
end