help-octave
[Top][All Lists]
Advanced

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

Re: The i operator


From: Maynard Wright
Subject: Re: The i operator
Date: Mon, 26 Jan 2009 08:05:45 -0800
User-agent: KMail/1.9.1

On Monday 26 January 2009 04:02, Ben Abbott wrote:
> On Jan 25, 2009, at 10:39 PM, Steve wrote:
> > Hi,
> >
> > I’d appreciate some advice with Octave and use of the i imaginary
> > operator.
> >
> > I can get this to work:
> >
> > octave-3.0.3.exe:27> (2 * (pi) * 10.7e6 * 1.62e-6i)
> >
> > ans = 0.00000 + 108.91273i
> >
> >
> > And this works where I define the constant w as 2*pi*10.7e6:
> >
> > octave-3.0.3.exe:28> w = 2 * (pi) * 10.7e6
> >
> > w = 6.7230e+007
> >
> > octave-3.0.3.exe:29> (w * 1.62e-6i)
> >
> > ans = 0.00000 + 108.91273i
> >
> > I’d like to also define the constant L and use it in the calculation,
> > but I get this error:
> >
> > octave-3.0.3.exe:30> w = 2 * (pi) * 10.7e6
> >
> > w = 6.7230e+007
> >
> > octave-3.0.3.exe:31> L = 1.62e-6i
> >
> > L = 0.0000e+000 + 1.6200e-006i
> >
> > octave-3.0.3.exe:32> w * Li
> >
> > error: `Li' undefined near line 32 column 5
> >
> > error: evaluating binary operator `*' near line 32, column 3
> >
> >
> > How does one use the i operator with constants so that Octave
> > recognizes
> > the i as the imaginary operator?
> >
> > Thanks.
> >
> > Steve
>
> I assume  you are asking for help, and not reporting a bug?
>
> For the first example, the following works
>
>       (2 * (pi) * 10.7e6 * 1.62*10^(-6i))
>       ans = 3.4432e+07 - 1.0333e+08i
>
> For the last, it can be wise to use 1i in the event "i" has been used
> as a variable.
>
>       w = 2 * (pi) * 10.7e6;
>       L = 1.62*10^(-6i);
>       w * L * 1i
>       ans = 1.0333e+08 + 3.4431e+07i
>
> Notice the answers for each of the above. The "i" is not part of the
> exponent.
>
> Evaluate 1e1i in either Matlab or Octave gives the same result.
>
>       1e1i
>       ans = 0 + 10i
>
> Thus, just like the answers above, 1e1i is interpreted as (1e1)*1i
>
> Ben
>

If the problem is to calculate the reactance of an inductor, then you 
can proceed as follows:

w = 2 * pi * 10.7e6;      # radian frequency
L = 1.62e-6;                 # inductance in henries
Xl = w * L * 1i;   

Xl will equal 0.00000 + 108.91273i, which is the impedance of the 
inductor, a purely imaginary quantity since there is no resistance
specified to produce a real component of impedance.

Note that you can omit "1" from "1i" here, but it may not be safe if
you have specified i as a variable anywhere. We can illustrate the
problem as follows:

octave: 1> w = 2 * pi * 10.7e6;   
octave: 2> L = 1.62e-6;
octave: 3> Xl = w * L * i         # This works correctly
Xl = 0.00000 + 108.91273i
octave: 4> i = 7;                   # Now define a variable i
octave: 5> Xl = w * L * i         # This now fails
Xl = 762.39
octave: 6> Xl = w * L * 1i       # This works correctly
Xl = 0.00000 + 108.91273i   


Maynard Wright


                                    



reply via email to

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