help-octave
[Top][All Lists]
Advanced

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

built-in variable i


From: Bart Vandewoestyne
Subject: built-in variable i
Date: Wed, 13 Aug 2008 14:16:41 +0200
User-agent: Mutt/1.5.13 (2006-08-11)

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."


reply via email to

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