Hi!

Using Octave 3.0.0 in Ubuntu 8.04, with the statistics-1.0.7 package
I'm having problems with the mad function.

octave:6> a=randn (1,30);
octave:7> mad(a);
usage: a = mad (X,dim)
error: evaluating if command near line 23, column 3
error: called from `mad' in file `/home/tulku/octave/statistics-1.0.7/mad.m'

I got the same error with all these commands:

octave:7> mad(a');
octave:7> mad(a,1);
octave:7> mad(a,2);

Interesting, the help mad output is:

octave:7> help mad
a = mad(X)
   mean absolute deviation of X

and it does not mention the "dim" argument.

Looking at the source code of the mad function I changed the offending
if, and seems to fix the problem. It is a very small change, showed in
the following diff:

--- mad.m       2008-10-15 12:53:57.000000000 -0300
+++ new-mad.m   2008-10-15 12:54:17.000000000 -0300
@@ -20,7 +20,7 @@
     dim = min(find(size(X)>1));
     if isempty(dim), dim=1; endif
   endif
-  if (nargin != 1 || nargin != 2)
+  if (nargin != 1 && nargin != 2)
     usage("a = mad (X,dim)");
   elseif (prod(size(X)) != size(X,dim))
 %   if (prod(size(X)) != size(X,dim))

The help string should also be fixed to include the dim argument.

Thank you very much!

Lucas Chiesa

"Oh no, not again."

- A bowl of petunias on it's way to certain death.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Octave-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/octave-dev

Reply via email to