function M = magic_odd ( n )

%*****************************************************************************80
%
%% magic_odd returns a MAGIC matrix of odd order.
%
%  Modified:
%
%    16 December 2019
%
%  Author:
%
%    The Mathworks, Inc.
%
%  Input:
%
%    integer N, the order of A.
%    N must not be divisible by 2.
%
%  Output:
%
%    real A(N,N), the matrix.
%
  [I,J] = ndgrid(1:n);
  A = mod(I+J+(n-3)/2,n);
  B = mod(I+2*J-2,n);
  M = n*A + B + 1;

  return
end

