From bug-request at octave dot org Wed May 25 12:17:24 2005 Subject: general load/save (in)compatibility From: Ben Barrowes To: bug at octave dot org Date: Wed, 25 May 2005 11:16:18 -0600 There are a number of compatibility problems regarding load/save between octave/matlab: - matlab's default save filetype is a matfile, instead of an octave -text file (octave's default), why is default_save_options = "-text"? Wouldn't it make sense to be compatible with matlab? Fix=> set default_save_options = "-mat"; - matlab appends a ".mat" onto saved files if there is no extension on the save filename and no filetype switch is given. Fix=> make octave add ".mat" in cases where the save filename has no file extension and no filetype switch is given *and* if default_save_options points to a matfile type. This extra test is required because matlab currently has no way to default to saving as ascii files. - octave's -text and -ascii (are these different?) save in a format incompatible with matlab. I think it would be compatible if the # comment character in octave's save format was changed to %. Then both matlab and octave could load the file. - when loading a file with no file extension. matlab assumes it is an ascii file, while octave tries to figure out(??). octave may have more functionality in this case, but the behavior is different with no warning issued. Fix=> perhaps none required. - octave apparently has no way to load ascii files containing numbers only. For example, if test2 contains: $ more test2 8.0000000e+00 1.0000000e+00 6.0000000e+00 3.0000000e+00 5.0000000e+00 7.0000000e+00 4.0000000e+00 9.0000000e+00 2.0000000e+00 matlab will put this into a variable called test2 when called with >> load test2 However, in octave load with either -text or -ascii both produce the error: octave:45> load -text test2 error: load: empty name keyword or no data found in file `test2' octave:45> apparently octave is looking for variable header information written when using octave's save -text, such as: # Created by Octave 2.9.3, Wed May 25 11:00:05 2005 MDT # name: aa # type: matrix # rows: 3 # columns: 3 8 1 6 3 5 7 4 9 2 Even if octave is changed in the future according to the warning: *WARNING: the meaning of this option will change in a future version of Octave to be compatible with MATLAB. To keep the meaning of your code the same across this change, use the `-text' option instead.* the default text save should be set to this matlab compatible -ascii and not -text (unless the fix above is applied and # is changed to % in save -text files. Note that in octave: load test2 load('test2') produce no results and no errors, and octave:59> a1=load('test2') error: value on right hand side of assignment is undefined error: evaluating assignment expression near line 59, column 3 octave:59> fails. ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------