From: Tom H. <to...@ku...> - 2005-05-29 12:59:53
|
On Sat, 28 May 2005, Paul Kienzle wrote: > An m x 1 vector of characters should be interpreted as an array > of length one strings. Good point. strcmp treats an m x n string array as m strings. Of course strtok doesn't work for string arrays, either: octave:4> s = ['abca';'fdag']; octave:5> strtok(s, 'a') error: mx_el_ne: nonconformant arguments (op1 is 3x1, op2 is 1x3) With my patch the result is the somewhat non-obvious octave:1> s = ['abca';'fdag']; octave:2> strtok(s, 'a') ans = fbdc That's wrong, too. It should be ['bc';'fd'], and I guess in the case where the result has different length rows the short ones should be padded with blanks. One could certainly argue that fread with 'char' should return strings, but since fread is documented as returning columns, for the other types this doesn't make sense. The default is uchar, too. Perhaps the documentation for fread could include a statement that if you specify 'char', you probably also want to transpose the output, to make it into a "string". Or a new 'string' type, as opposed to 'char', that does this. Dr. Tom Holroyd "A man of genius makes no mistakes. His errors are volitional and are the portals of discovery." -- James Joyce |