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: spm_range.m
    path of file: ./repos/automaticanalysis/external/MRtools/Utilities
    
    the code of the file until where you have to start completion: function y = spm_range(x,dim)

    
function y = spm_range(x,dim)
% Computes the difference between the min and max of a vector. If you need
% to use it on a matrix, then you need to specify which dimension to
% operate on.
if nargin < 2
    y = max(x) - min(x);
else
    y = max(x,[],dim) - min(x,[],dim);
end