help-octave
[Top][All Lists]
Advanced

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

Re: imaginary unit


From: Marek Szczypinski
Subject: Re: imaginary unit
Date: Thu, 27 Apr 2006 09:41:25 +0200 (CEST)

To avoid overwriting original value of i,j,etc. I am using ii or jj as a loop index. Works fine for me:)
Marek

Homo sum, humani nihil a me alienum puto.

On Wed, 26 Apr 2006, Przemek Klosowski wrote:

e^(i*pi) is the natural way of calculating vectors in complex
plane. It failed for me, though, and I realized that I used the
variable 'i' as a loop index, overwriting its original value of an
imaginary unit vector, which octave assigns on startup to i,I, j,J.

octave:1> i,j,I,J
i = 0 + 1i
j = 0 + 1i
I = 0 + 1i
J = 0 + 1i

All of those variables can be overwritten:

octave:2> i=j=I=J=1;i,j,I,J
i = 1
j = 1
I = 1
J = 1

so the safe way to use them is to use 1i etc.

octave:3> 1i,1j,1I,1J
ans = 0 + 1i
ans = 0 + 1i
ans = 0 + 1i
ans = 0 + 1i

Perhaps the use of predefined 'i' should elicit a warning?
_______________________________________________
Help-octave mailing list
address@hidden
https://www.cae.wisc.edu/mailman/listinfo/help-octave



reply via email to

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