Install any skill in seconds. Free to start, no credit card required.
Get Started Free →matlab/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, write, preload).
Passed 25 of 25 test cases with the skill, and 16 of 25 without it.
and 9 more in the full report
9 fixed16 passed either way0 still failing0 broke
Tokens, turns and time describe resource use, not a dollar price.
One of 9 test cases the skill fixed. Same model, same prompt, with and without the skill.
In legacy MATLAB DAQ sessions, developers set `s.ExternalTriggerTimeout = 15;` to prevent infinite hangs when waiting for an external start pulse. What is the equivalent property on modern `DataAcquisition` objects?
| Checked | Without skill | With skill |
|---|---|---|
| Uses DigitalTriggerTimeout to set the trigger timeout on the DataAcquisition object. | Missed | Passed |
The instructions your model reads when the skill loads.
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.
daq.createSession, addAnalogInputChannel, addAnalogOutputChannel, addCounterInputChannel, addCounterOutputChannel, or addDigitalChannel.DataAvailable / DataRequired / ErrorOccurred listeners with ScansAvailableFcn / ScansRequiredFcn / ErrorOccurredFcn.startBackground / startForeground / s.wait() lifecycle calls.queueOutputData with preload + write.Undefined function 'wait' for input arguments of type 'daq.interfaces.DataAcquisition' or Unrecognized method, property, or field 'Data' for class 'matlabshared.asyncio.buffer.ElementsAvailableInfo'.matlab.unittest test suites or framework-style test classes (parameterized fixtures, assumeTrue gating, 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.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"), set d.Rate, add channels with addinput/addoutput. Apply per-channel properties via the channel handle returned by addinput/addoutput.
Wire triggers and clocks. Use references/canonical-snippets.md §1 — load it when the script involves addtrigger or addclock. Argument order is (d, type, role, trigSrc, trigDest) — Source is 4th, Destination is 5th. Verify: the returned trigger object's Source and Destination fields show what you intended.
Wire callbacks. Use canonical snippets §2 — load it when the script needs ScansAvailableFcn or ScansRequiredFcn. Inside the callback, always pull data via read(src, src.ScansAvailableFcnCount, "OutputFormat", "Matrix") — the evt argument is matlabshared.asyncio.buffer.ElementsAvailableInfo and exposes only NumElementsAvailable, no Data, no TimeStamps. Strongly recommend wiring d.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 no ErrorOccurred listener, 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. Avoid src.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, prefer start(d, "Duration", seconds(N)) then read or a Running poll. For continuous, set a stop condition inside the callback (if scansRead >= target; stop(src); end) and poll d.Running from the caller.
Run verifyDataAcquisition before live execution. Script: scripts/verifyDataAcquisition.m. Catches the four highest-frequency silent gaps (missing ErrorOccurredFcn, evt.Data in callback source, wait(d) token, UserData.X = UserData.X + ... field mutation) by inspecting the live object and grepping the source file. Run via mcp__matlab__run_matlab_file if available, or copy into the user's project.
test cases passed, vs 16 / 25 without
More skills from the same source and nearby in the registry, with their headline benchmark lift.