[Fwd: How to make a read variable av lvalue?]
Thomas Weber
thomas.weber.mail at gmail.com
Wed Jan 23 02:43:46 CST 2008
Am Mittwoch, den 23.01.2008, 09:18 +0100 schrieb Svante Signell:
> This was sent to the wrong list. Hoping for some answers here.
>
> -------- Forwarded Message --------
> From: Svante Signell <svante.signell at telia.com>
> To: maintainers at octave.org
> Cc: svante.signell at telia.com
> Subject: How to make a read variable av lvalue?
> Date: Wed, 23 Jan 2008 08:19:21 +0100
>
> Dear list,
>
> I have the following problem when coding in Octave/Matlab. After reading
> a string from an external file into a variable, like x=fscanf(...)
> resulting in x='string' how can I use this variable content as an
> lvalue, like x.a='something', where x is replaced by its string value,
> resulting in string.a='something' instead of x.a='something'.
octave:1> x = "horray"
x = horray
octave:2> eval ([x, ".a = 300"]);
horray =
{
a = 300
}
octave:3> horray.a
ans = 300
> For functions calls eval() can be used but what about string
> substitution? BTW: We are writing som general software in Matlab/Octave
> and are planning to use eval() extensively in loops. How slow it is
> compared to fixed function calls?
You are combining two slow features, so expect it to be slow.
Thomas
More information about the Help-octave
mailing list