From bug-octave-request at bevo dot che dot wisc dot edu Thu May 31 14:31:29 2001 Subject: saving string matrices From: "John W. Eaton" To: Stef Pillaert Cc: bug-octave at bevo dot che dot wisc dot edu Date: Thu, 31 May 2001 14:31:07 -0500 On 29-May-2001, Stef Pillaert wrote: | To: bug-octave at bevo dot che dot wisc dot edu | Cc: stef | Subject: saving string matrices | -------- | Bug report for Octave 2.1.34 configured for i586-pc-linux-gnu | | Description: | ----------- | | When creating a string matrix, the way this matrix gets saved differs | depending on the way how it is created. I use the save-load-patch to save | structs in octave (provided by jcardoso, If I remember correctly...). | | Repeat-By: | --------- | I create both a & b, with the same result, but the saved file seems to make a | difference between them. However, in this case, it loads them both OK, but I | do have cases where reloading the file gives very strange results. | | Stef. | | octave:1> a=["abcd";setstr(97*ones(1,200))]; | octave:2> b(1,1:4)="abcd"; | octave:3> b(2,1:200)=setstr(97*ones(1,200)); | octave:4> save savetest.test a b | octave:5> exit | [stef at toneti testing2]$ less savetest.test | # Created by Octave 2.1.34, Tue May 29 14:55:56 2001 CEST | | # name: a | # type: string array | # elements: 2 | # length: 200 | abcd | | # length: 200 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | # name: b | # type: string array | # elements: 2 | # length: 200 | abcd^ at wn^@^@^@^@^@^@^@^@^@^M^@^@^@^P^@^@^@^A^@^@^@^@^@^@^@savetest dot test^@^@^@¨Ñ^^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ÈÑ^^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@èÑ^^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ | # length: 200 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | savetest.test (END) There are two problems here. One is that | octave:1> a=["abcd";setstr(97*ones(1,200))]; fills with the value of string_fill_char, but | octave:2> b(1,1:4)="abcd"; | octave:3> b(2,1:200)=setstr(97*ones(1,200)); does not (it fills with ASCII nul). The other problem is that the save function writes garbage after the first ASCII nul character. Both should be fixed in CVS now. Thanks, jwe ------------------------------------------------------------- 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 -------------------------------------------------------------