Reading from an Analog Input Channel
This example shows how to collect data from a SensorDAQ analog input channel using the Support Package.
This line will always be the same for any Support Package function that uses the Session-based interface (all but digital io).
s = sdaq.createSession;
This line adds analog input 0 (pin 11) to the session. To add analog input 1 instead (pin 12), simply change the 0 to a 1.
The first line retrieves one sample of voltage data from the device and stores it in data. The second line tells MATLAB to display the data.
data = s.inputSingleScan; data %#ok<NOPTS>
data = 1.4199
Deleting the session object prevents it from interfering with other session objects. Always do this when you're done with the channel (including from within a script or function). This will prevent odd errors elsewhere.
Note that if you're planning on acquiring multiple samples in one session, you don't have to delete the session until you're done. In fact, it's much faster to not have to create a new session every time you want data.
MATLAB Support Package for Vernier SensorDAQ Version 1.0