From bug-octave-request at bevo dot che dot wisc dot edu Fri Jul 21 15:57:23 2000 Subject: str2mat does not accept [] From: "John W. Eaton" To: pkienzle at kienzle dot powernet dot co dot uk (Paul Kienzle) Cc: bug-octave at bevo dot che dot wisc dot edu Date: Fri, 21 Jul 2000 15:57:24 -0500 (CDT) On 9-Jun-2000, Paul Kienzle wrote: | To: bug-octave at bevo dot che dot wisc dot edu | Cc: pkienzle | Subject: str2mat does not accept [] | | Bug report for Octave 2.0.13 configured for i386-pc-linux-gnu | | Description: | ----------- | | I'm trying to build a matrix of strings piecemeal using something like: | x=[]; | while !feof(file) | str = fscanf(file,"%s"); | str2mat(x,str); | endwhile | but str2mat does not accept [] as an empty string matrix. I'm not sure that I would call this a bug, since `[]' is an empty matrix, not a string. If you initialize x to be the empty string (x = "" instead of x = []), then I think it should work. jwe | I don't know what matlab behaviour is in this instance. | | Repeat-By: | --------- | | | Fix: | --- | | diff -c str2mat.m-2.1.28 str2mat | *** str2mat.m-2.1.28 Thu Jun 8 23:18:13 2000 | --- str2mat.m Thu Jun 8 23:26:52 2000 | *************** | *** 49,64 **** | s = va_arg (); | if (isstr (s)) | [nr(k), nc(k)] = size (s); | ! else | error ("str2mat: all arguments must be strings"); | endif | endfor | - | - tmp = find (nr == 0); | - | - if (! isempty (tmp)) | - nr(tmp) = 1; | - endif | | retval_nr = sum (nr); | retval_nc = max (nc); | --- 49,61 ---- | s = va_arg (); | if (isstr (s)) | [nr(k), nc(k)] = size (s); | ! if (nr(k) == 0) | ! nr(k) = 1; | ! endif | ! elseif (!isempty (s)) | error ("str2mat: all arguments must be strings"); | endif | endfor | | retval_nr = sum (nr); | retval_nc = max (nc); ----------------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.che.wisc.edu/octave/octave.html How to fund new projects: http://www.che.wisc.edu/octave/funding.html Subscription information: http://www.che.wisc.edu/octave/archive.html -----------------------------------------------------------------------