Skip to main content
Skip table of contents

MATLAB for LJM - Windows

MATLAB .NET example scripts for the LJM library.

Prerequisites

  • A T-series LabJack Device

  • LJM Library and .NET assembly - Install the LJM Library

  • MATLAB 7.8 (R2009a) or newer

  • Operating system - Windows

Latest Release Example Package

matlab_ljm_2017_12_04.zip

New Changes

  • Added new examples.

  • Added T4 support to examples.

Getting Started

  1. Go to your device Quickstart Tutorial and follow the steps to install LabJack software and confirm basic operation.

  2. Download/extract the .zip file attached at the top of this page.

  3. In MATLAB open, edit and run the script examples in extracted MATLAB_LJM folder. 

Note: Add example scripts to the MATLAB path before running, and all examples require the functions in showDeviceInfo.m and showErrorMessage.m.

Refer to the download's README.txt file for more details.

Where is an example to do XYZ?

You will find lots of examples in this archive, but there is not an example for everything the LabJack can do.  The reason for this stems from the "Overview" section above.  Most operations simply involve writing and reading different registers, so you really just need examples that show you how to write and read any register.  If we had examples for every operation, they would just be copies of the example "Write Read Loop with Config" with different registers. The typical workflow to do almost anything beside stream is:

  1. Look at the T-series Datasheet or the Modbus Map to determine what registers you need to write and read.

  2. Use the Register Matrix in Kipling to test writing and reading your desired registers and confirm you see what you expect to see.  This step is optional and not always applicable.

  3. Use eWriteName (or eWriteNames) to write the desired registers and eReadName (or eReadNames) to read the desired registers. Or just use "Write Read Loop with Config", which provides the basic structure used by many user applications.

Code Snippet

CODE
%Make the LJM .NET assembly visible in MATLAB
ljmAsm = NET.addAssembly('LabJack.LJM');

handle = 0;

try
    %Open first found LabJack
    [ljmError, handle] = LabJack.LJM.OpenS('ANY', 'ANY', 'ANY', handle);
    
    %Call eReadNames to read the serial number from the LabJack.
    name = 'SERIAL_NUMBER';
    [ljmError, value] = LabJack.LJM.eReadName(handle, name, 0);
    
    disp('eReadName result:')
    disp(['  ' name ' = ' num2str(value)])
catch e
    showErrorMessage(e)
end

Old Versions

Download MATLAB_LJM_2017_12_04.zip

  • 12/04/2017

  • Release

    • Added new examples.

    • Added T4 support to examples.

Download MATLAB_LJM_2014_01_14.zip

  • 01/14/2014

  • Release

File List

MATLAB_LJM_2017_12_04.zip contains:

LICENSE.txt
README.txt
Examples\getDeviceType.m
Examples\showDeviceInfo.m
Examples\showErrorMessage.m
Examples\Basic\eAddresses.m
Examples\Basic\eNames.m
Examples\Basic\eReadAddress.m
Examples\Basic\eReadAddresses.m
Examples\Basic\eReadName.m
Examples\Basic\eReadNames.m
Examples\Basic\eWriteAddress.m
Examples\Basic\eWriteAddresses.m
Examples\Basic\eWriteName.m
Examples\Basic\eWriteNames.m
Examples\More\AIN\DualAINLoop.m
Examples\More\AIN\SingleAIN.m
Examples\More\AIN\SingleAINWithConfig.m
Examples\More\Config\ReadConfig.m
Examples\More\Config\ReadDeviceNameString.m
Examples\More\Config\WriteDeviceNameString.m
Examples\More\Config\WritePowerConfig.m
Examples\More\DIO\SingleDIORead.m
Examples\More\DIO\SingleDIOWrite.m
Examples\More\Ethernet\ReadEthernetConfig.m
Examples\More\Ethernet\ReadEthernetMac.m
Examples\More\Ethernet\WriteEthernetConfig.m
Examples\More\I2C\I2CEeprom.m
Examples\More\ListAll\ListAll.m
Examples\More\SPI\SPI.m
Examples\More\Stream\StreamBasic.m
Examples\More\Stream\StreamBasicWithStreamOut.m
Examples\More\Stream\StreamBurst.m
Examples\More\Stream\StreamSequentialAIN.m
Examples\More\Testing\CRSpeedTest.m
Examples\More\Watchdog\ReadWatchdogConfig.m
Examples\More\Watchdog\WriteWatchdogConfig.m
Examples\More\WiFi\ReadWiFiConfig.m
Examples\More\WiFi\ReadWiFiMac.m
Examples\More\WiFi\ReadWiFiRssi.m
Examples\More\WiFi\WriteWiFiConfig.m

JavaScript errors detected

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

If this problem persists, please contact our support.