Skip to main content
Skip table of contents

MATLAB for UD - Windows

MATLAB examples for the Windows UD library. The Windows UD library is the high-level Windows library/driver for the LabJack U3, U6 and UE9. For other LabJack devices, go to the Software page.

Warning: If you intend to create a 64-bit application please ensure you use AddRequestPtr rather than AddRequest anywhere you write or read an array of data. See our AddRequest documentation for more information.

MATLAB .NET examples for R2009a (7.8) and later

The recommended examples for modern MATLAB. Requires MATLAB R2009a (7.8) and later. The ".NET Examples for MATLAB" attachment below provides examples that use the MATLAB .NET interface and the UD .NET assembly. No compiler tools are necessary. Refer to the README.txt in the download for details. Download dated 04/25/2018 are the latest.

Note to MATLAB 2018a and newer users: If you have script code using a LabJack that was working in previous MATLAB versions but is now getting "Undefined variable" errors when using enumerations, refer to the latest download's README.txt file, section "Changes for MATLAB 2018a and Newer", for solutions.

.NET Examples for MATLAB (04/25/2018)

.NET Examples for MATLAB (06/24/2014)

Old MATLAB examples for R2008b (7.7) and earlier

The old MATLAB drivers and examples version 1.32. See the PDF included in the download zip. Tested on MATLAB 7.0, but should work with 6.5 or newer.

This should work for most 32-bit versions of MATLAB. Due to how MATLAB handles calls to .dlls, additional steps are needed for work with 64-bit MATLAB. In addition to needing the 64-bit LabJackUD.dll you must also have a set of compiler tools to call the functions.  

See this for an example of how to set that up with MATLAB 7.7

For MATLAB R2010a you can get more information here for 32-bit versions and here for 64-bit versions.

For MATLAB R2011b you can get more information here for 32-bit versions and here for 64-bit versions.

For MATLAB R2012b you can get more information here for 32-bit versions and here for 64-bit versions.

For other versions please see the "Supported Compilers" column on this page.

Old Driver and Examples for MATLAB

UD Library Overview

First read the general overview of the UD library.

The UD driver has a handful of functions, many with the same 4 to 6 parameters.

Functions

The main functions are used to build a list of requests (Add), execute the list (Go), and read the result of each request (Get).  Some functions (e.g. eGet) combine a single add/go/get into one function call.

Parameters

The parameters are described at the bottom of the Overview page.  The meaning of each parameter should be apparent (e.g. Channel is the channel number you are operating on), but when it is not the pseudocode section of the device's datasheet has the extra information needed.

  • Handle:  Always the handle.

  • IOType:  Always the IOType.

  • Channel:  If something besides a channel number the pseudocode section will tell you.

  • Value:  Always the value.

  • X1:  Usually not used, but if used the pseudocode section will tell you.

  • UserData:  Usually not used, but if used the pseudocode section will tell you.

Pseudocode

Device specific pseudocode can be found in the device datasheet pseudocode section (U3/U6/UE9).

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.