help-octave
[Top][All Lists]
Advanced

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

Re: eval() for user-defined matrices?


From: Carlo de Falco
Subject: Re: eval() for user-defined matrices?
Date: Thu, 7 Sep 2006 10:56:43 +0200

On 9/7/06, the_verge <address@hidden> wrote:

Hi all,

Is there a way to implement eval("thing_x") if thing_x is a vector?  Or is
there some alternative command that will do the same thing?  For example:

thing_x = [1 3 6 9 0];
eval("thing_x")

returns "invalid vector index = 116"
instead of:

thing_x = 1 3 6 9 0

Any ideas on how to do this?
Note:  I would like class(eval(thing_x)) to be double

Thanks,
Vergil
--
View this message in context: 
http://www.nabble.com/eval%28%29-for-user-defined-matrices--tf2230998.html#a6183851
Sent from the Octave - General forum at Nabble.com.



If you define

thing_x = [1 3 6 9 0];

thing_x

thing_x =

 1  3  6  9  0

class (thing_x)
ans = double

you don't need to eval(), thing_x is already a vector of double...
what eval() does is

1) take _a_string_ as input
2) interpret the octave commands contained in the string
3) return the final result of the calculation as output

so you probably wanted to do:

thing_x = "[1 3 6 9 0]";
class(thing_x)
ans = char

eval(thing_x)
ans =

 1  3  6  9  0
class(ans)
ans = double

-
c.


reply via email to

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