SampleRate

Specify per-channel rate at which analog data is converted to digital data, or vice versa

Description

SampleRate specifies the per-channel rate (in samples/second) that an analog input (AI) or analog output (AO) subsystem converts data. AI subsystems convert analog data to digital data, while AO subsystems convert digital data to analog data.

AI and AO subsystems have a finite (though often large) number of valid sampling rates. If you specify a sampling rate that does not match one of the valid values, the data acquisition engine automatically selects the nearest available sampling rate. In most data acquisition hardware, some valid sample rates can be non integers. See The Sampling Rate for more info about valid sample rates.

Because the engine can set the sampling rate to a value that differs from the value you specify, you should return the actual sampling rate using the get function or the device object display summary. Alternatively, you can use the setverify function, which sets the SampleRate value and then returns the actual value that is set. To find out the range of sampling rates supported by your board, use the propinfo function. Additionally, because the actual sampling rate depends on the number of channels contained by the device object and the ChannelSkew property value (AI only), SampleRate should be the last property you set before starting the device object.

Characteristics

Usage

AI, AO, common to all channels

Access

Read/write

Data type

Double

Read-only when running

Yes

Values

The default value is obtained from the hardware driver.

Examples

Create the analog input object ai for a sound card and add two channels to it.

ai = analoginput('winsound');
addchannel(ai,1:2);

You can find out the range of valid sampling rates with the ConstraintValue field of the propinfo function.

rates = propinfo(ai,'SampleRate');
rates.ConstraintValue
ans =
        8000       48000

To configure the per-channel sampling rate to 48 kHz:

ai.SampleRate = 48000

Alternatively, you can use the setverify function to configure and return the SampleRate value.

ActualRate = setverify(ai,'SampleRate',48000);

See Also

Functions

propinfo, setverify

Properties

ChannelSkew

Was this topic helpful?