| Data Acquisition Toolbox | Search  Help Desk |
Setting and Verifying Hardware Properties
For theOutputRange and SampleRate properties, data acquisition devices have a finite (though sometimes large) number of valid values that you can set. If you specify a property value that does not match one of the valid device values, then the engine will choose a valid value automatically. The rules the engine uses to select a valid property value are described for each property in Chapter 7, "Property Reference."
You can use the propinfo function to obtain information about the valid values for these properties. For example, suppose you create the analog output object AO for a sound card. You can use propinfo to display information about the SampleRate property.
AO = analogoutput('winsound')
propinfo(AO, 'SampleRate')
ans =
Type: 'double'
Constraint: 'Bounded'
ConstraintValue: [8000 44100]
DefaultValue: 8000
ReadOnly: 0
ReadOnlyRunning: 1
DeviceSpecific: 0
To find out if the engine sets a property to a value that differs from the one you specified, you should get the value after it is set. For example, after setting the sampling rate for a sound card, you should retrieve the actual rate set since you may want to use this value to set additional property values.
AO = analogoutput('winsound')
addchannel(AO, 1)
set(AO, 'SampleRate', 8192)
ActualRate = get(AO,'SampleRate');
data = sin(0:(2*pi/ActualRate):2*pi)';
% Find the time required to output data
time = length(data)/ActualRate;
As an alternative to the syntax shown above, you can use the setverify function. setverify is equivalent to the commands
set(obj, 'Property', Value) Actual = get(obj, 'Property')Using
setverify, the previous example is written as
AO = analogoutput('winsound')
addchannel(AO, 1)
ActualRate = setverify(AO,'SampleRate', 8192)
data = sin(0:(2*pi/ActualRate):2*pi)';
% Find the time required to output data
time = length(data)/ActualRate;