By using the complex operation library, you can perform operations of complex numbers.
In the complex operation library, you can use the complex type (Complex) as a data type. Data of the complex type consists of a real part (.real) and an imaginary part (.imag) as shown in the following example.
Dim Num as Complex
Num.real=1.0
Num.imag=2.0
The following table lists the procedures included in the complex operation library.
Procedure name |
Function |
Sets a complex number. |
|
Sets a complex number. |
|
Converts a variant type or double floating point type array to a complex type array. |
|
Returns the result of the addition. |
|
Returns the result of the subtraction. |
|
Returns the result of the multiplication. |
|
Returns the result of the division. |
|
Returns the absolute value. |
|
Returns the phase angle. |
|
Returns the square of the absolute value. |
|
Returns the conjugate complex number. |
|
Returns the cosine. |
|
Returns the hyperbolic cosine. |
|
Returns the sine. |
|
Returns the hyperbolic sine. |
|
Returns ex. |
|
Returns the natural logarithm. |
|
Returns the common logarithm. |
|
Returns the square root. |
:
:
Dim Dmy As Long
Dim s21_raw As Variant
Dim s31_raw As Variant
Dim s21_Comp As Complex
Dim s31_Comp As Complex
Dim trAce_ratio_comp As Complex
Dim trAce_ratio(401) As Double
SCPI.DISPlay.Split = "D1"
SCPI.DISPlay.WINDow(1).Split = "D12_34"
SCPI.CALCulate(1).PARameter.Count = 2
SCPI.CALCulate(1).PARameter(1).DEFine = "s21"
SCPI.CALCulate(1).PARameter(2).DEFine = "s31"
SCPI.SENSe(1).SWEep.POINts = 201
:
:
:
SCPI.TRIGger.SEQuence.Source = "bus"
SCPI.TRIGger.SEQuence.SINGle
Dmy = SCPI.IEEE4882.OPC
'''' Get corrected data array
SCPI.CALCulate(1).PARameter(1).SELect
s21_raw = SCPI.CALCulate(1).SELected.DATA.SDATa
SCPI.CALCulate(1).PARameter(2).SELect
s31_raw = SCPI.CALCulate(1).SELected.DATA.SDATa
For i = 0 To 200
'''' Copy corrected data array to the complex data array
'''' to take advantage of complex operation library
s21_Comp = ComplexSet(s21_raw(2 * i), s21_raw(2 * i + 1))
s31_Comp = ComplexSet(s31_raw(2 * i), s31_raw(2 * i + 1))
'''' Calculate the ratio of S31 and S21
'''' S31/S21
trAce_ratio_comp = ComplexDiv(s31_Comp, s21_Comp)
trAce_ratio(2 * i) = trAce_ratio_comp.real
trAce_ratio(2 * i + 1) = trAce_ratio_comp.imag
Next i
SCPI.CALCulate(1).PARameter.Count = 4
'''' Write "S31/S21" data to corrected data array for the trace 3 (LogMag)
SCPI.CALCulate(1).PARameter(3).SELect
SCPI.CALCulate(1).SELected.Format = "MLOG"
SCPI.CALCulate(1).SELected.DATA.SDATa = trAce_ratio
'''' Write "S31/S21" data to corrected data array for the trace 4 (Phase)
SCPI.CALCulate(1).PARameter(4).SELect
SCPI.CALCulate(1).SELected.Format = "PHASe"
SCPI.CALCulate(1).SELected.DATA.SDATa = trAce_ratio
:
: