help-octave
[Top][All Lists]
Advanced

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

Re: [Fwd: How to make a read variable av lvalue?]


From: Muthiah Annamalai
Subject: Re: [Fwd: How to make a read variable av lvalue?]
Date: Tue, 22 Jan 2008 23:57:01 -0600
User-agent: Thunderbird 2.0.0.6 (X11/20071022)

Svante Signell wrote:
This was sent to the wrong list. Hoping for some answers here.

-------- Forwarded Message --------
From: Svante Signell <address@hidden>
To: address@hidden
Cc: address@hidden
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'.

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?

Thanks

I think using eval() is not a good idea in general, specifically if you want to eval()
input from the user, it could dangerously compromise security.

Maybe you should rework your algorithm?

There are ways to "install-global-variables" into Octave, and use them. You could
use a .oct file, and create the variable on the Octave symbol-table.

I suggest thinking of another way to do whatever you want to do right now. Loops aren't performance friendly either. Octave suggests users to vectorize the code.

-Muthu



reply via email to

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