Code covered by the BSD License  

Highlights from
Mac OS X Data Aquisition with National Instruments device

from Mac OS X Data Aquisition with National Instruments device by Fred Sigworth
Analog input with a National Instruments device on Mac OS X, using a mex file.

data=daqRead(h,nsamp,nchan)
function data=daqRead(h,nsamp,nchan)
% function data=daqRead(h,nsamp,nchan)
% Read samples on demand from a data acquisition device.  This function
% may be called only after calling daqInit and daqStart.
% h is the TaskHandle returned by daqInit.  nsamp is the number of samples
% per channel to acquire.  nchan is the number of channels (must be the
% same as the number given to daqStart).
% On my Macbook using the NI USB-6009 device this function takes about
% 5+.025n ms to read n samples.
% fs 7 September 2009

if nargin<3
    nchan=1;
end;
if nargin<2
    nsamp=1;
end;

timeout=1;  % 1 second timeout.

data=DAQ(int32(3),uint32(h),uint32(nsamp*nchan),double(timeout));

% if possible, reshape the output so that each channels' samples are in a
% column of the matrix.
if numel(data)==nsamp*nchan
    data=reshape(data,nsamp,nchan);
end;

Contact us at files@mathworks.com