This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Custom Functions

Custom functionality provided by your adaptor that is not part of the standard session-based interface can be exposed to MATLAB via the DAQ SDK custom interface. For example, your device might provide an on-board power supply.


This topic assumes experience writing MEX-files.

To add a custom function, first review the custom functions available in the demo adaptor in the folder matlabroot\matlab\toolbox\daq\daqsdk\+daq\+demoadaptor\+custom. The installed files in this folder are:


Use these steps to create your own custom function:

  1. Add a function to the MyDriver class (MyDriver::customFunction).

  2. Add a function to the MyAdaptor class (MyAdaptor::customFunction) that calls MyDriver::customFunction with the designated:

    • Inputs

    • Outputs

    • Custom error code

  3. Update custom_my.cpp to:

    • Define a function to call (dispatch) the custom adaptor function MyAdaptor::customFunction.

    • Update the customizeMap function to add:

      functionMap["myCustomFunction"] = customFunction;

      where customFunction is the name of the MEX-function that calls MyAdaptor::customFunction, and myCustomFunction is the name of function in MATLAB.

  4. Define your custom MATLAB function myCustomFunction.m in the +daq\+myadaptor\+custom subpackage for your adaptor.

    • Choose the appropriate template from \+daq\+demoadaptor\+custom\ to copy and rename.

      • Has Inputs, Has Outputs

      • Has Inputs, No Outputs

      • No Inputs, No Outputs

    • Rename the file to perform the desired function, for example, myCustomFunction.m.

    • Edit myCustomFunction.m to

      • Update: functionName = 'myCustomFunction';

      • Provide the inputs to the function as a structure.

For functionality that is not part of the standard session interface, contact MathWorks® technical support at to let us know what functionality you need.

Related Topics