Code covered by the BSD License  

Highlights from
Interfacing to External Devices from MATLAB

Interfacing to External Devices from MATLAB

by

 

28 Apr 2003 (Updated )

A collection example code for interfacing to external devices

daq_session.m
%% Example data acquisition session
% This demonstration shows the procedure for acquiring data
% This demo requires the Data Acquisition Toolbox

% Copyright 2003 The MathWorks, Inc

%% Create the object and add one channel
ai = analoginput('winsound');       %Create
addchannel(ai,1);                   

% Let's look at the object
ai

% Let's look at the object in more detail
get(ai)                    

%% Configure the analog input parameters
set(ai, 'SampleRate', 44100);       %Configure

%% Start the object.  
% With the default settings, it will record for 1 second.
start(ai)

%% Get the data
[data,time]=getdata(ai);
plot(time,data)

%% Clean up
delete(ai)
clear ai  

Contact us