I-J Square Root of Negative One

Section: Base Constants

Usage

Returns a complex value that represents the square root of -1. There are two functions that return the same value:
   y = i

and

   y = j.

This allows either i or j to be used as loop indices. The returned value is a 32-bit complex value.

Example

The following examples demonstrate a few calculations with i.
--> i
ans = 
  <complex>  - size: [1 1]
  0+ 1 i  
--> i^2
ans = 
  <complex>  - size: [1 1]
  -1+  0 i  

The same calculations with j:

--> j
ans = 
  <complex>  - size: [1 1]
  0+ 1 i  
--> j^2
ans = 
  <complex>  - size: [1 1]
  -1+  0 i  

Here is an example of how i can be used as a loop index and then recovered as the square root of -1.

--> accum = 0; for i=1:100; accum = accum + i; end; accum
ans = 
  <int32>  - size: [1 1]
 5050  
--> i
ans = 
  <int32>  - size: [1 1]
 100  
--> clear i
--> i
ans = 
  <complex>  - size: [1 1]
  0+ 1 i