From: Paul K. <pki...@us...> - 2005-05-28 19:48:29
|
This seems to be a request for bug-for-bug compatibility. An m x 1 vector of characters should be interpreted as an array of length one strings. The fact that fread is returning the wrong orientation for a character array shouldn't require us to make an ugly interface to all our string functions. I'm not going to 'fix' this, but if someone else feels so inclined they may. - Paul On May 15, 2005, at 5:24 PM, Tom Holroyd wrote: > fread with 'char' returns a column array; eventually this got passed > to strtok. In strtok, there's a > skip = find(idx != 1:length(idx)) > which failed because 1) there were multiple instances of the > delimiter, and 2) idx is a column and the : is a row. > For example, in matlab: > >> s = 'abca'; > >> strtok(s, 'a') > > ans = > > bc > > >> strtok(s', 'a') > > ans = > > b > c > > In octave: > octave:1> s = 'abca'; > octave:2> strtok(s, 'a') > ans = bc > octave:3> strtok(s', 'a') > error: mx_el_ne: nonconformant arguments (op1 is 2x1, op2 is 1x2) > > One way to fix this is: > --- #strtok.m 2005-05-15 16:18:02.000000000 -0400 > +++ strtok.m 2005-05-15 16:47:53.000000000 -0400 > @@ -57,6 +57,7 @@ > tok = str; > rem = ""; > else > + idx = reshape(idx, [1 length(idx)]); > skip = find(idx != 1:length(idx)); # find first non-leading > delimiter > if isempty(skip) > tok = str(idx(length(idx))+1:length(str)); > > -- > Dr. Tom Holroyd > "A man of genius makes no mistakes. His errors are volitional and > are the portals of discovery." -- James Joyce > > > ------------------------------------------------------- > This SF.Net email is sponsored by Oracle Space Sweepstakes > Want to be the first software developer in space? > Enter now for the Oracle Space Sweepstakes! > http://ads.osdn.com/?ad_id=7393&alloc_id=16281&op=click > _______________________________________________ > Octave-dev mailing list > Oct...@li... > https://lists.sourceforge.net/lists/listinfo/octave-dev > |