matlab-modernize-daq
Port MATLAB Data Acquisition Toolbox code from the discouraged (legacy) session-based interface (daq.createSession, addAnalogInputChannel, startBackground, DataAvailable listeners, queueOutputData, wait) to the recommended DataAcquisition interface (daq("ni"), addinput, start, ScansAvailableFcn, wri…
Install / Use
npx skills add matlab/matlab-agentic-toolkit --skill matlab-modernize-daqInstalls into whichever agent you are using.
SKILL.md
Installable skill definition
Quality Score
Category
Content & MediaSupported Platforms
Our assessment of matlab-modernize-daq
matlab-modernize-daq scores 93/100 on our quality scale, 246th of 1,200 Content & Media skills we index (top 21%).
Its SKILL.md is 18 KB long, well organised into 14 sections with 5 code examples: a thorough specification that gives an agent plenty to work with.
With 1,098 GitHub stars, it is one of the more widely adopted skills in the catalogue.
Maintenance, license and trust
- The repository was last updated 18 days ago, so matlab-modernize-daq is actively maintained.
- No license is declared. By default that means all rights are reserved: you can read it, but reusing or redistributing it is not clearly permitted. Ask the author before building on it commercially.
- Its trust signals score 88/100, with 1 caution from licensing, adoption, age or documentation. These come from repository metadata, not a code audit — read the skill file before letting an agent act on it.
matlab-modernize-daq compared with similar skills
All 4 of these similar skills score higher than matlab-modernize-daq; compare them before choosing.
| Skill | Score | Stars | Updated | Format |
|---|---|---|---|---|
| matlab-modernize-daq (this skill)by matlab | 93 | 1.1k | 18d ago | SKILL.md |
| Agent-Reachby Panniantong | 100 | 89.8k | 18d ago | CLAUDE.md |
| headroomby headroomlabs-ai | 100 | 74.4k | today | CLAUDE.md |
| Scraplingby D4Vinci | 100 | 85.4k | today | MCP Server |
| crawl4aiby unclecode | 100 | 84.7k | 8d ago | MCP Server |
Frequently asked questions
- How do I install matlab-modernize-daq?
- Run
npx skills add matlab/matlab-agentic-toolkit --skill matlab-modernize-daq. The install tabs above show the steps for each supported agent. - Which AI agents does matlab-modernize-daq work with?
- It is written for Universal, as a SKILL.md file. Other agents that read the same format can often use it too.
- Is matlab-modernize-daq safe to use?
- It declares no license and scores 88/100 on trust signals. Skills are instructions an agent will follow, so read the file before installing it and do not approve commands you do not understand.
- Is matlab-modernize-daq still maintained?
- The repository was last updated 18 days ago, so matlab-modernize-daq is actively maintained.
Skill content
View source on GitHubname: matlab-modernize-daq description: > Port MATLAB Data Acquisition Toolbox code from the discouraged (legacy) session-based interface (daq.createSession, addAnalogInputChannel, startBackground, DataAvailable listeners, queueOutputData, wait) to the recommended DataAcquisition interface (daq("ni"), addinput, start, ScansAvailableFcn, write, preload). Use when migrating legacy DAQ scripts, converting session-API calls, working with DataAcquisition objects, writing multi-feature DAQ scripts that combine triggers, callbacks, continuous acquisition, or analog output. Also use when a user says their DAQ script "used to work" or "errors on R20XX", since modernizing legacy session-API code is a frequent fix for those failures. Trigger keywords: daq, DAQ, NI, session interface, addtrigger, addclock, ScansAvailableFcn, ScansRequiredFcn, daq.createSession, addAnalogInputChannel, startBackground, queueOutputData, DataAvailable, evt.Data, evt.TimeStamps, wait(d), preload, discouraged, legacy, modernize, R2020a. license: https://www.mathworks.com/content/dam/mathworks/license/pmrl/license.md metadata: author: MathWorks version: "1.0"
Port DAQ Code to the Modern DataAcquisition Interface
Translate legacy session-based Data Acquisition Toolbox code (daq.createSession, addAnalogInputChannel, DataAvailable listeners, startBackground, queueOutputData, wait) to the modern DataAcquisition interface introduced in R2020a (daq("ni"), addinput, ScansAvailableFcn, start, write, preload). Also covers writing new multi-feature DAQ scripts where the modern API patterns are easy to get wrong under cognitive load.
When to Use
- Porting an existing script that calls
daq.createSession,addAnalogInputChannel,addAnalogOutputChannel,addCounterInputChannel,addCounterOutputChannel, oraddDigitalChannel. - Replacing
DataAvailable/DataRequired/ErrorOccurredlisteners withScansAvailableFcn/ScansRequiredFcn/ErrorOccurredFcn. - Replacing
startBackground/startForeground/s.wait()lifecycle calls. - Replacing
queueOutputDatawithpreload+write. - Writing a new DAQ script that combines two or more of: external triggers, continuous acquisition, callback-driven streaming, analog output with refill, or cross-callback state.
- Debugging errors like
Undefined function 'wait' for input arguments of type 'daq.interfaces.DataAcquisition'orUnrecognized method, property, or field 'Data' for class 'matlabshared.asyncio.buffer.ElementsAvailableInfo'.
When NOT to Use
- Single-channel foreground acquisition with no trigger and no callbacks (e.g. "acquire 1 s of voltage from ai0 at 10 kHz and plot"). The modern API is straightforward at this scale and this skill would be unnecessary overhead.
- Picking a DAQ vendor or evaluating non-NI hardware. This skill's evidence base is NI.
- Signal processing or analysis of already-acquired data (filtering, spectral analysis, etc.). This skill only covers acquiring and generating data through the DataAcquisition interface, not post-processing it.
- Simulink, App Designer, or real-time-target DAQ workflows.
- Modernizing
matlab.unittesttest suites or framework-style test classes (parameterized fixtures,assumeTruegating, arity-contract tests, helper-class hierarchies). The API substitutions in this skill apply, but the test-harness scaffolding (parent-class stripping, fixture redesign, retiring tests that target removed contracts) is out of scope. Use this skill to translate the API calls inside test bodies, then make the harness-level judgment calls separately.
Workflow
When porting a session-based script or composing a new multi-feature DAQ script, follow this order. Verify after every step — most failure modes in this domain are silent.
-
Inventory the legacy script (porting only). Identify: device(s), channel types, rate, continuous vs finite, trigger/clock connections, callbacks (
DataAvailable/DataRequired/ErrorOccurred), state shared across callbacks, output queueing. -
Translate vocabulary. Map every session-API token to its modern counterpart. Consult
references/session-to-modern-mapping.md— load it whenever a session-API token appears in the legacy script. Common silent-rename traps:NotifyWhenDataAvailableExceeds→ScansAvailableFcnCount,NumberOfScans/NumScans→ implicit (no equivalent argument),ExternalTriggerTimeout→DigitalTriggerTimeout,IsContinuous=true→start(d, "Continuous")argument. -
Build the DataAcquisition object.
d = daq("ni"), setd.Rate, add channels withaddinput/addoutput. Apply per-channel properties via the channel handle returned byaddinput/addoutput. -
Wire triggers and clocks. Use
references/canonical-snippets.md§1 — load it when the script involvesaddtriggeroraddclock. Argument order is(d, type, role, trigSrc, trigDest)— Source is 4th, Destination is 5th. Verify: the returned trigger object'sSourceandDestinationfields show what you intended. -
Wire callbacks. Use canonical snippets §2 — load it when the script needs
ScansAvailableFcnorScansRequiredFcn. Inside the callback, always pull data viaread(src, src.ScansAvailableFcnCount, "OutputFormat", "Matrix")— theevtargument ismatlabshared.asyncio.buffer.ElementsAvailableInfoand exposes onlyNumElementsAvailable, noData, noTimeStamps. Strongly recommend wiringd.ErrorOccurredFcn = @(~,evt) fprintf("DAQ error: %s\n", evt.Error.message)— without it, exceptions inside other callbacks are silently swallowed and the run "succeeds" while every fire throws. For strict ports where the legacy script had noErrorOccurredlistener, surface this trade-off to the user instead of silently adding the handler — let them opt in. -
Pick a state-sharing pattern (callbacks only). If a callback needs to maintain state across fires (running counters, phase accumulator, latch flags), see
references/callback-state-patterns.md— load it any time a callback maintains state. Default: handle-class wrapper or nested function. Avoidsrc.UserData.X = src.UserData.X + ...field-mutation; it does not persist. -
Wire the lifecycle. Use canonical snippets §3 — load it when blocking on completion. There is no
wait(d)method on the modern object. For finite acquisitions, preferstart(d, "Duration", seconds(N))thenreador aRunningpoll. For continuous, set a stop condition inside the callback (if scansRead >= target; stop(src); end) and polld.Runningfrom the caller. -
Run
verifyDataAcquisitionbefore live execution. Script:scripts/verifyDataAcquisition.m. Catches the four highest-frequency silent gaps (missingErrorOccurredFcn,evt.Datain callback source,wait(d)token,UserData.X = UserData.X + ...field mutation) by inspecting the live object and grepping the source file. Run viamcp__matlab__run_matlab_fileif available, or copy into the user's project. -
Live verification. Run a short version (e.g. 1–2 s instead of the user's full duration). Check that the script reaches
startcleanly, that the callback fires at least once, and that no errors print fromErrorOccurredFcn. Usemcp__matlab__run_matlab_fileagainst a saved.mfile, notmcp__matlab__evaluate_matlab_code— the eval-string buffer runs in script mode and rejects local/nested function definitions, which Pattern 5 and most callback bodies require.
Key Functions
| Function | Purpose | Toolbox | Available From |
|----------|---------|---------|----------------|
| daq | Create a DataAcquisition object (d = daq("ni")) | Data Acquisition Toolbox | R2020a |
| addinput | Add input channel (analog, counter, or digital) | Data Acquisition Toolbox | R2020a |
| addoutput | Add output channel | Data Acquisition Toolbox | R2020a |
| addtrigger | Add trigger connection: addtrigger(d, type, role, trigSrc, trigDest) | Data Acquisition Toolbox | R2020a |
| addclock | Add clock connection (similar signature) | Data Acquisition Toolbox | R2020a |
| read | Foreground acquire OR pull data inside ScansAvailableFcn | Data Acquisition Toolbox | R2020a |
| write | Write output samples (also from inside ScansRequiredFcn) | Data Acquisition Toolbox | R2020a |
| preload | Load initial output buffer before start(d, "Continuous"). Output channels only. | Data Acquisition Toolbox | R2020a |
| start | Begin background acquisition: start(d), start(d, "Continuous"), start(d, "Duration", seconds(N)) | Data Acquisition Toolbox | R2020a |
| stop | Stop a running acquisition | Data Acquisition Toolbox | R2020a |
| flush | Discard buffered scans before reading | Data Acquisition Toolbox | R2020a |
| daqlist | Enumerate available devices (replaces daq.getDevices) | Data Acquisition Toolbox | R2020a |
| daqreset | Reset DAQ subsystem (replaces daq.reset) | Data Acquisition Toolbox | R2020a |
Properties on DataAcquisition: Rate, Running, NumScansAcquired, NumScansOutputByHardware, ScansAvailableFcn, ScansAvailableFcnCount, ScansRequiredFcn, ScansRequiredFcnCount, ErrorOccurredFcn, DigitalTriggerTimeout, UserData.
Patterns
The five canonical patterns below appear in full, with verified code, in references/canonical-snippets.md. Inline below is the minimal recall snippet for each — enough to anchor the agent's memory under load. Load the reference for the full, runnable forms.
Pattern 1: Add an external start trigger
trg = addtrigger(d, "Digital", "StartTrigger", "External", "Dev1/PFI0");
trg.Condition = "RisingEdge";
d.DigitalTriggerTimeout = 30;
The 4th argument is the Source ("External" for an external signal). The 5th is the Destination (the device terminal). Reversing them is the most-frequent error in this domain. The trigger condition ("RisingEdge", "FallingEdge") is set on the trigger object returned by addtrigger (trg.Condition), not on the DataAcquisition object. There is no d.DigitalTriggerCondition property — inventing one passes static lint but errors at runtime.
Pattern 2: ScansAvailableFcn body — pull data via read, never evt.Data
d.ScansAvailableFcnCount = round(d.Rate * 0.5);
d.ScansAvailableFcn = @(src, ~) onBlock(src);
d.ErrorOccurredFcn = @(~, evt) fprintf("DAQ error: %s\n", evt.Error.message);
function onBlock(src)
[data, t] = read(src, src.ScansAvailableFcnCount, "OutputFormat", "Matrix");
plot(t, data); drawnow limitrate;
end
The evt argument carries only NumElementsAvailable; it has no Data or TimeStamps. Wiring ErrorOccurredFcn is strongly recommended — without it, callback exceptions are silently swallowed and the run "succeeds" while every fire throws. For strict ports of legacy scripts that did not have an ErrorOccurred listener, ask the user before adding one rather than inserting it silently.
Pattern 3: Block until acquisition completes — there is no wait(d)
start(d, "Duration", seconds(10));
while d.Running
pause(0.05);
end
wait(d) does not exist on daq.interfaces.DataAcquisition. Poll d.Running, or rely on start(d, "Duration", ...) + a stop condition inside the callback.
Pattern 4: Continuous AO playback with auto-refill
d = daq("ni");
d.Rate = 1000;
addoutput(d, "Dev1", "ao0", "Voltage");
d.ScansRequiredFcnCount = d.Rate;
d.ScansRequiredFcn = @(src, ~) write(src, generateNextBlock());
preload(d, generateNextBlock());
preload(d, generateNextBlock());
start(d, "Continuous");
preload is output-only — calling it on input-only setups errors. Two preloaded blocks before start give the buffer headroom for the first
Truncated for display — read the full file on GitHub.
Related Skills
Agent-Reach
89.8kGive your AI agent eyes to see the entire internet. Read & search Twitter, Reddit, YouTube, GitHub, Bilibili, XiaoHongShu — one CLI, zero API fees.
headroom
74.4kCompress tool outputs, logs, files, and RAG chunks before they reach the LLM. 20% fewer tokens for coding agents, 60-95% fewer tokens for JSON, same answers. Library, proxy, MCP server.
Scrapling
85.4k🕷️ An adaptive Web Scraping framework that handles everything from a single request to a full-scale crawl! Don't be shy, join here: https://discord.gg/EMgGbDceNQ and follow here for daily tips and tricks: https://x.com/Scrapling_dev
crawl4ai
84.7kOpen-source web crawler and scraper for LLMs and AI agents: any website into clean, LLM-ready Markdown. Run it yourself, or use Crawl4AI Cloud with one key.
Languages
Trust signals
From repository metadata: license, adoption, age and documentation. Not a code audit — see the Safety scan above for what the skill file itself contains.
