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_ndgrid.m
    path of file: ./repos/spm
    
    the code of the file until where you have to start completion: function [X,s] = spm_ndgrid(x)
% Return a matrix of grid points in the domain specified by x
% FORMAT [X,x] = spm_ndgrid(x)
%
% x{i):   cell array of vectors specifying support or;
% x(i):   vector of bin numbers in the range [-1 1]
%
% x{i):   cell array of vectors specifying support or;
% X:      (n x m) coordinates of n points in m-D space
%__________________________________________________________________________

% Karl Friston
% Copyright (C) 2005-2022 Wellcome Centre for Human Neuroimaging


% event-space: domain s
%--------------------------------------------------------------------------

    
function [X,s] = spm_ndgrid(x)
% Return a matrix of grid points in the domain specified by x
% FORMAT [X,x] = spm_ndgrid(x)
%
% x{i):   cell array of vectors specifying support or;
% x(i):   vector of bin numbers in the range [-1 1]
%
% x{i):   cell array of vectors specifying support or;
% X:      (n x m) coordinates of n points in m-D space
%__________________________________________________________________________

% Karl Friston
% Copyright (C) 2005-2022 Wellcome Centre for Human Neuroimaging


% event-space: domain s
%--------------------------------------------------------------------------
n  = length(x);
if iscell(x)
    s = x;
else
    for i = 1:n
        s{i} = linspace(-1,1,x(i));
    end