help-octave
[Top][All Lists]
Advanced

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

Re: Double problem in Matlab's magic.m


From: Henry F. Mollet
Subject: Re: Double problem in Matlab's magic.m
Date: Fri, 09 May 2003 14:19:22 -0700
User-agent: Microsoft-Entourage/10.1.1.2418

> That said, you can solve all of your problems by using the version of
> magic.m that is included in Octave-Forge (http://octave.sf.net).
> regards,
> Quentin Spencer

Thanks. I've downloaded and saved as 'magic.m' the following:

## Copyright (C) 1999-2001 Paul Kienzle
CUT
## magic(n)
## Create an n-by-n magic square.
## Note that magic(2) is undefined since there is no 2x2 magic square.
function A = magic(n)
  if nargin != 1 || n != floor(n) || n < 0 || n == 2
    usage("magic (n), n != 2");
  endif
  if (n == 0)
    A=[];
  elseif (mod(n,2) == 1)
CUT

And tried it:
octave:7> M=magic(5)
error: `mod' undefined near line 32 column 11
error: evaluating index expression near line 32, column 11
error: evaluating binary operator `==' near line 32, column 20
error: if: error evaluating conditional expression
error: evaluating if command near line 28, column 3
error: called from `magic' in file `/Users/mollet/ClassWWB/magic.m'

octave:7> help mod
help: sorry, `mod' is not documented

Presumably, 'mod' is modulus function but it's not in the GNU Octave
Function Index (Hard Copy for Octave version 2.0.13) and  help cannot find
it in my copy either (GNU Octave, version 2.1.35 (powerpc-apple-darwin6.2).
However, the Octave program 'magic' by PK is using it?
Henry



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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