From help-octave-request at bevo dot che dot wisc dot edu Mon Dec 30 19:59:49 2002 Subject: RE: Strings not compatible with Matlab? From: "Julian DeMarchi" To: "Paul Kienzle" Cc: "James Frye" , "John W. Eaton" , Date: Mon, 30 Dec 2002 20:58:42 -0500 . . . | >There's also the poor man's (older Matlab) hack -- basically same as the above -- declaring | > | > function assignin(ws,name,v); | > evalin(ws, [name '=' num2str(v)]); | > | >..which works because num2str() acts more accurately as if it would be called makestr() (turns anything into type string, meaning the function does not break even when v is not numeric). | > | >As for Octave, if you hack | > | > function evalin(ws,name,v); | > eval([name '=' num2str(v)]); | > | >Then you're all set. | > | > | | I believe you mean assignin here. Regardless, it will not work. If | it does, that means there is a bug in octave. | Hmmm. It definitely worked in Octave when I tested it. However I did not test it with the name evalin, I tested it with the name "function test()". Perhaps that was the bug you meant? Sorry if so. Nor does it work when endfunction is at the end of the file, though it does when endfunction is not there. Hence my deference regarding scope. I guess that somehow endfunction "sutures up" the scope of the function/script. I was misleading about the num2str() however; this only works when double quotes are used. | >(Octave/forge supports neither assignin nor evalin.) | > | | octave now supports evalin (cvs version). | Fabulous! - Julian/MatLinks ------------------------------------------------------------- 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 -------------------------------------------------------------