diff src/data.cc @ 3195:7a5a5da64756

[project @ 1998-10-28 22:54:04 by jwe]
author jwe
date Wed, 28 Oct 1998 23:01:17 +0000
parents edaa9a2d3d9c
children 44d82b369c78
line wrap: on
line diff
--- a/src/data.cc
+++ b/src/data.cc
@@ -598,6 +598,30 @@
   return retval;
 }
 
+DEFUN (length, args, ,
+  "length (x): return the `length' of the object X\n\
+\n\
+For matrix objects, the length is the number of rows or columns,\n\
+whichever is greater (this odd definition is used for compatibility\n\
+with Matlab).\n\
+\n\
+See also: size, rows, columns, is_scalar, is_vector, is_matrix")
+{
+  octave_value retval;
+
+  if (args.length () == 1)
+    {
+      int len = args(0).length ();
+
+      if (! error_state)
+	retval = static_cast<double> (len);
+    }
+  else
+    print_usage ("length");
+
+  return retval;
+}
+
 DEFUN (size, args, nargout,
   "[m, n] = size (x): return rows and columns of X\n\
 \n\