matlab-modernize-daq

Migrate legacy session-based MATLAB Data Acquisition Toolbox code to the modern DataAcquisition interface.

995|122|Updated Apr 3, 2026
One-click install
npx skills add https://github.com/matlab/matlab-agentic-toolkit --skill matlab-modernize-daq
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: matlab-modernize-daq
Source: https://github.com/matlab/matlab-agentic-toolkit/tree/main/skills-catalog/test-and-measurement/matlab-modernize-daq
Command: npx skills add https://github.com/matlab/matlab-agentic-toolkit --skill matlab-modernize-daq

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

Legacy MATLAB DAQ scripts built on the session-based interface (daq.createSession, addAnalogInputChannel, startBackground) are discouraged and often break on newer releases, and verbatim ports to the modern DataAcquisition API fail silently through traps like reversed trigger arguments, missing wait methods, and non-persistent callback state.

Core Features & Use Cases

  • API Translation: Maps every session-API token (listeners, queueOutputData, IsContinuous, wait) to its modern DataAcquisition equivalent (ScansAvailableFcn, preload/write, start with Duration or Continuous).
  • Verified Patterns: Provides five canonical, hardware-verified snippets covering external triggers, callback data reads, blocking until completion, continuous analog output with refill, and multi-channel triggered streaming.
  • Silent-Failure Detection: Ships a verifyDataAcquisition.m script that statically checks for the four highest-frequency silent gaps before live execution.
  • Use Case: A user's DAQ script errors with "Undefined function 'wait'" after upgrading MATLAB; use this Skill to port the script to daq("ni"), addinput, and a Running-poll loop, then verify it before running on hardware.

Quick Start

Port my legacy DAQ script that uses daq.createSession and startBackground to the modern DataAcquisition interface and verify it before running.

Frequently Asked Questions about matlab-modernize-daq

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I migrate MATLAB daq.createSession code to the new DAQ interface?

Replace daq.createSession('ni') with daq("ni"), swap addAnalogInputChannel for addinput, and replace startBackground with start(d, "Continuous") or start(d, "Duration", seconds(N)). Listener events like DataAvailable become object properties such as ScansAvailableFcn.

Why does my DAQ callback throw errors on evt.Data in modern MATLAB?

The modern ScansAvailableFcn event argument is matlabshared.asyncio.buffer.ElementsAvailableInfo, which exposes only NumElementsAvailable and has no Data or TimeStamps fields. Pull data inside the callback with read(src, src.ScansAvailableFcnCount, "OutputFormat", "Matrix") instead.

What replaces the wait() method on a DataAcquisition object?

There is no wait method on daq.interfaces.DataAcquisition. For finite acquisitions use start(d, "Duration", seconds(N)) and poll with while d.Running, pause(0.05); end, or set a stop condition inside the callback for continuous acquisition.

Why does my DAQ callback counter reset on every fire?

Mutating fields via src.UserData.X = src.UserData.X + n does not persist across callback fires and fails silently. Use a nested function capturing state by reference, a handle-class wrapper, or a whole-struct UserData rewrite instead.

When should I not use this DAQ modernization skill?

Skip it for simple single-channel foreground acquisition with no triggers or callbacks, where the modern API is straightforward. It also does not cover Simulink or App Designer DAQ workflows, non-NI hardware selection, or post-processing of acquired data.