Reads analog inputs
data = mdaqAIRead(channels, range, isDifferential) data = mdaqAIRead(linkID, channels, range, isDifferential)
This function returns immediately acquired values from MicroDAQ input channels as a 1-by-n array of doubles. The value is stored in data, where n is the number of input channels. The channels parameter can be a scalar or vector and it should contain channels numbers according to MicroDAQ hardware configuration. The range argument specifies channel measurement input range. Matrix n-by-2 where n is number of used channels shall be provided. If 1x2 matrix is provided, the range setting will be used for all channels. In order to obtain supported ranges use mdaqHWInfo(). The isDifferential argument specifies measurement mode - differential or single-ended. This argument can be scalar or vector (if applicable for MicroDAQ hardware configuration). If scalar provided, its value will be used for all used channels.
For function usage description call function without arguments.
linkID: Valid connection link id (optional)
channels: Scalar or vector with channels to be read
Analog input channel selection for differential terminal configuration:
range: Range matrix - single row matrix e.g. [-10,10] sets -10 to 10V input range which will be used for all channels. If multi-range used, row number must match selected channels e.g. range matrix for 3 channels [-10,10; -5,5; -2,2]
isDifferential: Scalar or vector with terminal configuration settings: %T - differential, %F - single-ended mode
data: Values of acquired data
Read 8 single-ended channels with same channel input rage
data = mdaqAIRead(1:8, [-10,10], %F); mprintf('Acquired data: %fV\t%fV\t%fV\t%fV\t%fV\t%fV\t%fV\t%fV \n', data) | ![]() | ![]() |
Read 4 single-ended channels with different channel input rage
NOTE: Example will work if applicable for MicroDAQ analog input configuration
data = mdaqAIRead(1:4, [-10,10; -5,5; -5,5; -10,10], %F); mprintf('Acquired data: %fV\t%fV\t%fV\t%fV\n', data) | ![]() | ![]() |
Read 1 differential channel, 2 single-ended channels with different channel input rage
NOTE: Example will work if applicable for MicroDAQ analog input configuration
data = mdaqAIRead([1 3 4], [-10,10; -5,5; -10,10], [%T %F %F]); mprintf('Acquired data: %fV\t%fV\t%fV\n', data) | ![]() | ![]() |
Performance comparison with and without linkId parameter
// mdaqAIRead usage example with and wihtout linkID parameter tic(); for i = 1:10 mdaqAIRead(1, [-10,10], %F); end read_time = toc(); mprintf("\nExecution time for ten mdaqAIRead() call without linkId: \t%fs \n", read_time); // Create connection with MicroDAQ beafore mdaqAIRead() call linkID = mdaqOpen(); tic(); for i = 1:10 mdaqAIRead(linkID, 1, [-10,10], %F); end read_time = toc(); mdaqClose(linkID); mprintf("Execution time for ten mdaqAIRead() call with linkId: \t%fs\n", read_time); | ![]() | ![]() |