From help-octave-request at bevo dot che dot wisc dot edu Mon Dec 30 01:07:48 2002 Subject: Strings not compatible with Matlab? From: "John W. Eaton" To: James Frye Cc: help-octave at bevo dot che dot wisc dot edu Date: Mon, 30 Dec 2002 01:07:19 -0600 On 29-Dec-2002, James Frye wrote: | Here's another Matlab compatability problem. The scripts we have pass | arguments as string/value pairs, for instance | | foo ("bar", 1); | | Function foo then scans its arguments, matching the values to variables | corresponding to the strings, so that variable bar would be set to 1. | | This doesn't work in octave. Arrays of strings seem to be treated as | though the strings were being concatenated into one long array of | characters. If I call the test program below as | | args ("hello"); | | it says that it's getting 5 arguments, each being one character of | "hello". I get similar behavior with internally-defined arrays of | strings. Suggestions? | | James | | | % test function to echo string arguments | | function args (argv) | | argc = length (argv); | printf ("argc = %d\n", argc); | | for i = 1:argc | printf ("arg %d = %s\n", i, argv (i)); | end | endfunction That doesn't look like something that will work in Matlab, since it has ", printf, and endfunction. In any case, the function Does the following for me when run in Matlab: >> args ('hello') argc = 5 arg 1 = h arg 2 = e arg 3 = l arg 4 = l arg 5 = o and Octave (2.1.40): octave:1> args ('hello') argc = 5 arg 1 = h arg 2 = e arg 3 = l arg 4 = l arg 5 = o Seems to behave the same in both. Can you provide a better example of something that doesn't work in a compatible way? If you think you have found a bug, can you please submit a complete bug report to the bug-octave mailing list? If you're not sure what to include in a complete report, please read the bugs chapter of the Octave manual (you can find a copy at www.octave.org/bugs.html). 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 -------------------------------------------------------------