Why does the Data Acquisition Toolbox “read” function return faster than the specified “span” in MATLAB R2025b?

I am using the "read" function from the Data Acquisition Toolbox in MATLAB R2025b to read data from a device. I want to collect data for 3 seconds. The documentation describes a "span" parameter, which can be specified as a duration. When I call "read(dq, seconds(3))", and I notice the call executes for less than 3 seconds when timed using "tic" and "toc". How is this possible?

 Respuesta aceptada

It’s possible for “read” to execute for a time shorter than the specified "span" if the data buffer already has data when “read” is called. The example below illustrates this behavior.
dq = daq("ni");
addinput(dq, "Dev1", "ai0", "Voltage");
start(dq, "continuous");
pause(1);
tic;
data = read(dq, seconds(3));
elapsed = toc();
stop(dq);
dataSpan = seconds(max(data.Time) - min(data.Time));
fprintf("Recorded elapsed time: %.3f s\n", elapsed); % ~2.000 s
fprintf("Data time span: %.3f s\n", dataSpan); % ~3.000 s

Más respuestas (0)

Categorías

Más información sobre Data Acquisition Toolbox Supported Hardware en Centro de ayuda y File Exchange.

Productos

Versión

R2025b

Preguntada:

el 17 de Abr. de 2026 a las 0:00

Respondida:

el 5 de Mayo de 2026 a las 15:23

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by