matlab中magic(2)的结果是什么意思啊?为什么他的结果和magic的其他值不一样啊

来源:百度知道 编辑:UC知道 时间:2024/05/12 07:20:04

M = magic(n) returns an n-by-n matrix constructed from the integers 1 through n^2 with equal row and column sums.

该函数返回一个由整数1到整数n^2组成的n*n矩阵。
该矩阵的行与列的和相同。

M = magic(3)

M =

8 1 6
3 5 7
4 9 2

sum(M) =

15 15 15

sum(M')' =

15
15
15

等于2的时候不能满足条件。

MAGIC Magic square.
MAGIC(N) is an N-by-N matrix constructed from the integers 1 through N^2 with equal row, column, and diagonal sums.
Produces valid magic squares for all N > 0 except N = 2.