I am writing a Genesys 2007.03 function to post-process measured 1-port s-parameter data.
I import the datafile into a dataset called Data1.
The function will calculate mismatch loss. It fails when the reflection coefficient magnitude exceeds 1 because mismatch loss takes the log of 1-(mag)^2).
I want to add a check for points that produce invalide mismatch loss. The function has a for loop that checks each row of the data vector, and then stores the result in an array.
To handle data with different numbers of points (i.e., different numbers of rows in the data vector), I want to declare an output array using the function size(Data1).
The line to define this array is
out = array(size(Data1).
Unfortunately, size(Data1) returns a REAL result, and array(n) requires an INTEGER argument.
Is there a way to either:
a) convert a real number to integer?
b) declare a varaible as an integer?
Many thanks.
I import the datafile into a dataset called Data1.
The function will calculate mismatch loss. It fails when the reflection coefficient magnitude exceeds 1 because mismatch loss takes the log of 1-(mag)^2).
I want to add a check for points that produce invalide mismatch loss. The function has a for loop that checks each row of the data vector, and then stores the result in an array.
To handle data with different numbers of points (i.e., different numbers of rows in the data vector), I want to declare an output array using the function size(Data1).
The line to define this array is
out = array(size(Data1).
Unfortunately, size(Data1) returns a REAL result, and array(n) requires an INTEGER argument.
Is there a way to either:
a) convert a real number to integer?
b) declare a varaible as an integer?
Many thanks.
The error message you're getting is somewhat misleading. The issue is that 1) the arguments of the array function can't be a vector, they have to be actual scalars (which I think should be changed in the future) and 2) Real arguments are fine, but Complex arguments are not.
Here is a way to do what you're trying to do:
sizevector = size( Data1 )
numElements = prod( size( sizevector ) )
numElements = real( numElements ) 'make sure its real, not complex
MyArray = array( numElements ) ' 1-D array with correct number of elements
MyArray = reshape( MyArray, sizevector )
Let me know if this doesn't work for you,
Dan Savio