| Data Acquisition Toolbox | Search  Help Desk |
Setting Property Values
As discussed in "Property Names and Property Values" in Chapter 2, the Data Acquisition Toolbox supports two basic types of properties: base properties and device-specific properties. Base properties apply to all supported hardware devices while device-specific properties are incorporated into the toolbox on a per-device basis. For analog input objects, the base properties are divided into two groups: common properties and channel properties. Common properties apply to all channels in a channel group while channel properties apply on a per-channel basis. You can set property values for the device object or one or more channels using theset command or subscripted assignment. For channels, you can use the set command to assign multiple property values for multiple channels. This feature is discussed below.
Setting Multiple Property Values for Multiple Channels
Using theset command, you can assign different values for multiple properties and multiple channels.
where:chans = obj.Channel(index);set(chans, {P1}, {V1},...);
chans is an m-by-1 array of channels
{P1} is a 1-by-n cell array of properties
{V1} is an m-by-n cell array of property values
V1 corresponds to a different channel, each column of V1 corresponds to a different property, and Vmn is the value to set for property n of channel m.
For example, suppose you create the analog input object AI for a sound card, and configure it for stereo operation. The code shown below illustrates how you can assign a different value to the SensorRange and ChannelName properties for each channel using a single call to set.
Alternatively, you can set these property values one channel at a timemyAI = analoginput('winsound');addchannel(myAI, 1:2);chans = myAI.Channel(1:2);set(chans, {'SensorRange', 'ChannelName'}, {[-2 2], 'Chan1';... [0 4], 'Chan2'});
or one channel and one property at a time.set(chans(1), 'SensorRange', [-2 2], 'ChannelName', 'Chan1');set(chans(2), 'SensorRange', [0 4], 'ChannelName', 'Chan2');
Note:set(chans(1), 'SensorRange', [-2 2]);set(chans(1), 'ChannelName', 'Chan1');set(chans(2), 'SensorRange', [-0 4]);set(chans(2), 'ChannelName', 'Chan2');