magic

Magic square

Syntax

  • M = magic(N)

Input argument

  • N - Matrix order, specified as a scalar integer.

Output argument

  • M - result of magic function.

Description

M = magic(N) computes an square matrix constructed as an arrangement of the 1:n^2 such that the row sums, column sums, and diagonal sums are all equal to the same value.

Example

M = magic(3)

See also

ones.

History

VersionDescription

1.0.0

initial version

Author

Allan CORNET

Last updated