help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Matlab test for magic requested


From: Nicholas Jankowski
Subject: Re: Matlab test for magic requested
Date: Sun, 13 Dec 2015 22:52:52 -0500

On Sun, Dec 13, 2015 at 7:18 PM, Richard Balogh <address@hidden> wrote:
On 12.12.2015 22:12, Andreas Weber wrote:
Hi Richard, thank you very much.

Am 12.12.2015 um 19:50 schrieb Richard Balogh:
magic (1.5)

ans =

      1

Oh, this wasn't expected. Can you try other non integer values? For
example magic(2.1), magic(2.8), can you see a system?


 magic(2.1)

ans =

     1     3
     4     2

>>  magic(2.8)

ans =

     1     3
     4     2



From the magic help:


"If you supply n less than 3, magic returns either a nonmagic square, or else the degenerate magic squares 1 and []."

if you step through 0 to 3, the ruleset basically follows:

magic(n), 0<=n<1 = []    (tested to 1-eps)
magic(n), 1<=n<2 = 1   (tested to 2-eps)
magic(n), 2<=n<3 = [1,3;4,2]  (tested to 3-eps)

also, note results from negatives:
magic(0) = []
magic(-0.1) = []
magic(-1) = []

magic (-2)
Subscript indices must either be real positive integers or logicals.

Error in magic (line 35)
   M([i; i+p],j) = M([i+p; i],j);

magic(-1+eps) = []

magic(-1-eps)
Subscript indices must either be real positive integers or logicals.

Error in magic (line 35)
   M([i; i+p],j) = M([i+p; i],j);


nick j.

 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]