Wavecom W-BitView V2.5.00 User Manual

Page 81

Advertising
background image

BitView Manual V2.5.00 WAVECOM W-BV

Custom Library

75

// to be of type double, outpar5 is of type string
// Use Intellisense to see all available classes
// the matlab deploytool generates a class by using the MatLab function name
// with 'class' appended:

MatlabFunctionclass MatlabFunc = new MatlabFunctionclass(); // new instance
of MatLab function

// now call this function, with 6 output parameters : y and outpar 1...5
argsOut = MatlabFunc.MatlabFunction(6, data, (double)Inpar1, (double)Inpar2);

// now get all results from argsOut, its an array of numeric/char arrays
// the first entry is our bit array result, can be of type numeric(double) or
logical,
// depending on the matlab function internal code

if ((argsOut[0].IsNumericArray) && (argsOut[0].NumberofDimensions == 2))
// if numeric and number of dimension exactly 2
{
MWNumericArray numericBits = (MWNumericArray)argsOut[0]; // cast to
MWNumericArray
MWNumericType numericType = numericBits.NumericType; // get the
numeric type, can be double, float, int, etc..., this has to be checked
Array numericBitsArray = numericBits.ToVector(MWArrayComponent.Real);
// must be anything but not complex !!!
int length;

switch (numericType) // check types, we expect double
{
case MWNumericType.Double:
double[] doubleArray = (double[])numericBitsArray; // cast to
double array
length = doubleArray.Length;
if (length > MAX_SIZE)
{
length = MAX_SIZE;
}
// convert now result to type of BitArray
for (int i = 0; i < length; ++i)
{
outbox[i] = (doubleArray[i] == 0.0) ? false : true;
}
outbox.Length = length; // set length explicitely, otherwise we
have MAX_SIZE !!
break;

case MWNumericType.Int32:
Int32[] int32Array = (Int32[])numericBitsArray; // cast to int32
array
length = int32Array.Length;
if (length > MAX_SIZE)
{
length = MAX_SIZE;
}
// convert now result to type of BitArray
for (int i = 0; i < length; ++i)
{
outbox[i] = (int32Array[i] == 0) ? false : true;
}
outbox.Length = length; // set length explicitely, otherwise we
have MAX_SIZE !!
break;

case MWNumericType.Int16:
Int16[] int16Array = (Int16[])numericBitsArray; // cast to int16
array
length = int16Array.Length;
if (length > MAX_SIZE)
{
length = MAX_SIZE;
}
// convert now result to type of BitArray
for (int i = 0; i < length; ++i)
{
outbox[i] = (int16Array[i] == 0) ? false : true;
}

Advertising
This manual is related to the following products: