# HG changeset patch # User jwe # Date 972958130 0 # Node ID e6d0041aedf3972abceb43efb9b91e0a3cc6ae0a # Parent b7d997d593d95d18056b3eeed09a23fb1b6d02a6 [project @ 2000-10-31 02:08:49 by jwe] diff --git a/scripts/ChangeLog b/scripts/ChangeLog --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,7 @@ +2000-10-27 Mats Jansson + + * set/create_set.m: Avoid empty matrix in matrix list warning. + 2000-09-08 Teemu Ikonen * plot/errorbar.m, plot/__errplot__.m: New functions. diff --git a/scripts/set/create_set.m b/scripts/set/create_set.m --- a/scripts/set/create_set.m +++ b/scripts/set/create_set.m @@ -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 diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2000-10-30 John W. Eaton + + * 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 . + 2000-10-27 John W. Eaton * Makefile.in (ops.cc): Don't substitute BLAS_LIBS and LIBS here. diff --git a/src/load-save.cc b/src/load-save.cc --- a/src/load-save.cc +++ b/src/load-save.cc @@ -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 @@ -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\