diff scripts/general/triu.m @ 7618:3209a584e1ac

Further type preservation tests and fix of diag for cell arrays
author David Bateman <dbateman@free.fr>
date Thu, 20 Mar 2008 20:54:19 +0100
parents 83a8781b529d
children eb63fbe60fab
line wrap: on
line diff
--- a/scripts/general/triu.m
+++ b/scripts/general/triu.m
@@ -27,10 +27,11 @@
 function retval = triu (x, k)
 
   if (nargin > 0)
+    if (isstruct (x))
+       error ("tril: structure arrays not supported");
+     endif 
     [nr, nc] = size (x);
-    retval = resize (resize (x, 0), nr, nc);
   endif
-
   if (nargin == 1)
     k = 0;
   elseif (nargin == 2)
@@ -41,6 +42,7 @@
     print_usage ();
   endif
 
+  retval = resize (resize (x, 0), nr, nc);
   for j = max (1, k+1) : nc
     nr_limit = min (nr, j-k);
     retval (1:nr_limit, j) = x (1:nr_limit, j);