[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: string to variable?
From: |
Carlo de Falco |
Subject: |
Re: string to variable? |
Date: |
Mon, 4 Sep 2006 19:43:43 +0200 |
On 9/4/06, José Luis García Pallero <address@hidden> wrote:
thing_a = 2;
x = sprintf('%d[or %f, etc.]',thing_a);
I don't think that's what he actually wants:
octave:1> thing_a = 2;
octave:2> x = sprintf("%d",thing_a)
x = 2
octave:3> class(x)
ans = char
i.e. x is a string variable containing the char "2"
I guess he wants to do:
octave:4>y = "thing_a"
octave:5> x = eval(y)
x = 2
octave:6>class(x)
ans = double
x is now the number 2
c.
This would give
x == "2" (class ), not x == 2
You should eval