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: resize_scales.m
    path of file: ./repos/spm12/@file_array/private
    
    the code of the file until where you have to start completion: function s1 = resize_scales(s0,dim,args)
% Resize scalefactors 

    
function s1 = resize_scales(s0,dim,args)
% Resize scalefactors 
%__________________________________________________________________________
% Copyright (C) 2005-2017 Wellcome Trust Centre for Neuroimaging

%
% $Id: resize_scales.m 7147 2017-08-03 14:07:01Z spm $


dim = [dim ones(1,max(numel(args)-numel(dim),0))];
args1 = cell(1,numel(args));
for i=1:numel(args)
    if max(args{i})>dim(i) || min(args{i})<1
        error('Index exceeds matrix dimensions (1).');
    end