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


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.



AI, AO, common to all channels



Data type


Read-only when running



The default value is obtained from the hardware driver.


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

ai = analoginput('winsound');

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

rates = propinfo(ai,'SampleRate');
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


propinfo, setverify



Was this topic helpful?