help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Strings not compatible with Matlab?


From: Julian DeMarchi
Subject: RE: Strings not compatible with Matlab?
Date: Mon, 30 Dec 2002 17:55:02 -0500

Hi James.

Not to add to the confusion, but there already exists a built-in function for 
your purpose (in Matlab R13):

>> help assignin

 ASSIGNIN Assign variable in workspace.
    ASSIGNIN(WS,'name',V) assigns the variable 'name' in the
    workspace WS the value V.  WS can be one of 'caller' or 'base'. 
 
    See also EVALIN.

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.  (Octave/forge supports neither assignin nor evalin.)

Disclaimer: Note however I am not entirely clear on how Octave variable scope 
is handled.  I notice that the above example works fine in octave so long as 
endfunction is not used to conclude function evalin(). 


Julian


-----Original Message-----
From: James Frye [mailto:address@hidden
Sent: Monday, December 30, 2002 1:27 PM
To: John W. Eaton
Cc: address@hidden
Subject: Re: Strings not compatible with Matlab?


On Mon, 30 Dec 2002, John W. Eaton wrote:

> That doesn't look like something that will work in Matlab, since it
> has ", printf, and endfunction.
...
> Can you provide a better example of something that doesn't work in a
> compatible way?

I hadn't tried that short example with matlab (since it was Sunday, and I
would have had to drive into the lab and boot the machine that has Matlab
on it, and that would have cut into my skiing time).  However, it's
abstracted from one of the scripts, which I didn't want to send to the
list since it's about 1200 lines.  If you're interested, I could email it
and a data file.

I ought to mention again that I didn't write these scripts.  The only 
contact I've had with Matlab is to start it, run one of them, and look at 
the output to figure out what the code I'm supposed to be writing is 
doing.

> 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).

I'll have a look at that, especially as I seem to have found more problems 
with fread...

James



-------------------------------------------------------------
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
-------------------------------------------------------------




-------------------------------------------------------------
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
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]