built-in variable i
Bart Vandewoestyne
Bart.Vandewoestyne at telenet.be
Wed Aug 13 07:16:41 CDT 2008
Hello,
I have just tested some code that I developed on Octave 2.9.12 on
an instance of Octave 2.1.69. I noticed difference in behavior
due to the following apparent difference concerning the handling
of the built in variable i:
octave:19> version
ans = 2.1.69
octave:20> i = 2; feval(@(x) x^i, 2)
ans = 0.76924 + 0.63896i
octave:3> version
ans = 2.9.12
octave:4> i = 2; feval(@(x) x^i, 2)
ans = 4
The second form is what one would intuitively expect and is also what
Matlab returns.
I often have i as the index for my for-loops, and then i often use this
index i in my functions. Unfortunately, it gets interpreted as sqrt(-1)
which is not what I want. Is there a way to prevent this in Octave 2.1.69
(it would be nice if i could get my code running on 2.1.69 without having
to change all the indexes in my for-loops...) Can I maybe change the
feval command?
Thanks,
Bart
--
"Share what you know. Learn what you don't."
More information about the Help-octave
mailing list