Indicate offset to use when converting between native data format and doubles
Note: You cannot use the legacy interface on 64-bit MATLAB®. See About the Session-Based Interface to acquire and generate data on a 64-bit MATLAB.
NativeOffset, along with
NativeScaling, is used to convert data between
the native hardware format and doubles.
For analog input objects, you return native data from the engine
getdata function. Additionally,
if you log native data to a
.daq file, then you
can read back that data using the
The formula for converting from native data to doubles is
doubles data = (native data)(native scaling) + native offset
For analog output objects, you queue native data in the engine
putdata function. The
formula for converting from doubles to native data is
native data = (doubles data)(native scaling) + native offset
You return the native data type of your hardware device with
daqhwinfo function. Note that
NativeScaling value for a given channel might
change if you change its
OutputRange (AO) property value.
You might want to return or queue data in native format to conserve memory and to increase data acquisition or data output speed.
AI, AO, per channel
Read-only when running
The default value is device-specific.
Create the analog input object
ai for a National Instruments® board,
and add eight channels to it.
ai = analoginput('nidaq','Dev1'); addchannel(ai,0:7);
ai, collect one second of data for
each channel, and extract the data from the engine using the native
format of the device.
start(ai) nativedata = getdata(ai,1000,'native');
You can return the native data type of the board with the
out = daqhwinfo(ai); out.NativeDataType
ans = double
Convert the data to doubles using the
scaling = ai.Channel(1).NativeScaling; offset = ai.Channel(1).NativeOffset; data = double(nativedata)*scaling + offset;