changeset 3727:e6d0041aedf3

[project @ 2000-10-31 02:08:49 by jwe]
author jwe
date Tue, 31 Oct 2000 02:08:50 +0000
parents b7d997d593d9
children 184043403776
files scripts/ChangeLog scripts/set/create_set.m src/ChangeLog src/load-save.cc
diffstat 4 files changed, 38 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Fri Oct 27 17:51:27 2000 +0000
+++ b/scripts/ChangeLog	Tue Oct 31 02:08:50 2000 +0000
@@ -1,3 +1,7 @@
+2000-10-27  Mats Jansson  <mats.e.jansson@home.se>
+
+	* set/create_set.m: Avoid empty matrix in matrix list warning.
+
 2000-09-08  Teemu Ikonen  <tpikonen@pcu.helsinki.fi>
 
 	* plot/errorbar.m, plot/__errplot__.m: New functions.
--- a/scripts/set/create_set.m	Fri Oct 27 17:51:27 2000 +0000
+++ b/scripts/set/create_set.m	Tue Oct 31 02:08:50 2000 +0000
@@ -45,7 +45,12 @@
     [nrx, ncx] = size (x);
     nelx = nrx * ncx;
     y = sort (reshape (x, 1, nelx));
-    y = y ([1, (find (y(1:nelx-1) != y(2:nelx)) + 1)]);
+    els = find (y(1:nelx-1) != y(2:nelx));
+    if (isempty (els));
+      y = y(1);
+    else
+      y = y([1, els+1]);
+    endif
   endif
 
 endfunction
--- a/src/ChangeLog	Fri Oct 27 17:51:27 2000 +0000
+++ b/src/ChangeLog	Tue Oct 31 02:08:50 2000 +0000
@@ -1,3 +1,9 @@
+2000-10-30  John W. Eaton  <jwe@bevo.che.wisc.edu>
+
+	* load-save.cc (do_load): Allow result to be returned instead of
+	inserting variables in the symbol table.  Change patterned after
+	patch by Kian Ming Adam Chai <caijianming@yahoo.co.uk>.
+
 2000-10-27  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
 	* Makefile.in (ops.cc): Don't substitute BLAS_LIBS and LIBS here.
--- a/src/load-save.cc	Fri Oct 27 17:51:27 2000 +0000
+++ b/src/load-save.cc	Tue Oct 31 02:08:50 2000 +0000
@@ -22,6 +22,7 @@
 
 // Written by John W. Eaton.
 // HDF5 support by Steven G. Johnson.
+// Matlab v5 support by James R. Van Zandt.
 
 #ifdef HAVE_CONFIG_H
 #include <config.h>
@@ -2907,13 +2908,15 @@
   return retval;
 }
 
-static octave_value_list
+static octave_value
 do_load (std::istream& stream, const std::string& orig_fname, bool force,
 	 load_save_format format, oct_mach_info::float_format flt_fmt,
 	 bool list_only, bool swap, bool verbose, bool import,
 	 const string_vector& argv, int argv_idx, int argc, int nargout)
 {
-  octave_value_list retval;
+  octave_value retval;
+
+  Octave_map retstruct;
 
   std::ostrstream output_buf;
   int count = 0;
@@ -3002,7 +3005,15 @@
 		    }
 		  else
 		    {
-		      install_loaded_variable (force, name, tc, global, doc);
+		      if (nargout == 1)
+			{
+			  if (format == LS_MAT_ASCII)
+			    retval = tc;
+			  else
+			    retstruct[name] = tc;
+			}
+		      else
+			install_loaded_variable (force, name, tc, global, doc);
 		    }
 		}
 
@@ -3043,6 +3054,8 @@
 
       delete [] msg;
     }
+  else if (! retstruct.empty ())
+    retval = retstruct;
 
   return retval;
 }
@@ -3083,6 +3096,12 @@
 both of these cases are likely to be the result of some sort of error,\n\
 they will generate warnings.\n\
 \n\
+If invoked with a single output argument, Octave returns data instead\n\
+of inserting variables in the symbol table.  If the data file contains\n\
+only numbers (TAB- or space-delimited columns), a matrix of values is\n\
+returned.  Otherwise, @code{load} returns a structure with members\n\
+ corresponding to the names of the variables in the file.\n\
+\n\
 The @code{load} command can read data stored in Octave's text and\n\
 binary formats, and @sc{Matlab}'s binary format.  It will automatically\n\
 detect the type of file and do conversion from different floating point\n\