Source code template / example (matlab), Matlabfunction.m – Wavecom W-BitView V2.5.00 User Manual

Page 82

Advertising
background image

76

Custom Library

BitView Manual V2.5.00 WAVECOM W-BV

outbox.Length = length; // set length explicitely, otherwise we
have MAX_SIZE !!
break;

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


default: // other numeric types not supported
throw new ApplicationException("Bad type returned from " +
FunctionName);
}
}
else if ((argsOut[0].IsLogicalArray) && (argsOut[0].NumberofDimensions == 2))
// if logical and number of dimension exactly 2
{
MWLogicalArray logicalBits = (MWLogicalArray)argsOut[0]; // cast
to MWLogicalArray

bool[] boolOutputArray;
boolOutputArray = logicalBits.ToVector(); // convert all to a bool
array in .net
outbox = new BitArray(boolOutputArray); // then initialize a
BitArray for use with BitViewTool
}
else
{
throw new ApplicationException("Bad type returned from " + FunctionName);
}

// now get other results, we do not check types again, but you should do that
outpar1 = (int)(MWNumericArray)argsOut[1];
outpar2 = (int)(MWNumericArray)argsOut[2];
outpar3 = (int)(MWNumericArray)argsOut[3];
outpar4 = (int)(MWNumericArray)argsOut[4];
outpar5 = ((MWCharArray)argsOut[5]).ToString();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString(), "Errors in " + FunctionName);
outbox.Length = 0;
}

return (outbox);

}
#endregion
}
}

Source Code Template / Example (MatLab)

MatlabFunction.m

function [y, outpar1, outpar2, outpar3, outpar4, outpar5] = MatlabFunction( x, inpar1, inpar2
)
%
%--------------------------------------------------------------------------
% Example of a function to be called from .Net environment, especially from

Advertising
This manual is related to the following products: