[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Newbie - can't find function
From: |
Paul Kienzle |
Subject: |
Re: Newbie - can't find function |
Date: |
Sun, 22 Apr 2001 03:47:48 +0100 |
User-agent: |
Mutt/1.2.5i |
On Sat, Apr 21, 2001 at 01:55:30PM +0100, Matteo Bettella wrote:
>
> On Sat, 21 Apr 2001, Brent W. Woodruff wrote:
>
> > Hello,
> > I'm new to the world of octave and despite my best efforts in the function
> > index and help files, I can't find the command for mod. Is it in there or
> > do
> > I need to write an octave program to do it?
> >
>
> I think you don't.
> >From the documentation:
>
> Mapping Function: rem (x, y)
> Return the remainder of x / y, computed using the expression
>
> x - y .* fix (x ./ y)
>
> An error message is printed if the dimensions of the arguments do not
> agree, or if either of the arguments is complex.
>
>
> Is this what you need?
> Regards,
> Matteo
>
This won't work corrrectly for negative valued x. Instead you want
x - y .* floor (x ./ y)
Another caveat is that Matlab's function mod(x,0) returns x, so for
complete compatibility you must trap for y == 0. Although arguably
wrong since lim_{y -> 0}{x-y*floor(x/y)} = 0, this behaviour is
implemented in:
http://users.powernet.co.uk/kienzle/octave/matcompat/scripts/specfun/mod.m
Paul Kienzle
address@hidden
>
>
>
> -------------------------------------------------------------
> 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
> -------------------------------------------------------------
>
>
-------------------------------------------------------------
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
-------------------------------------------------------------