MATLAB: How to set Data Acquisition Toolbox to read data from devices at a rate higher than 10Hz

daqData Acquisition Toolboxsampling rate

I am using the Data Acquisition Toolbox in MATLAB R2020b, and connecting to devices that are able to sample data at a very high frequency (~3000Hz), and I would like to use MATLAB to read the data buffer in the device as fast as possible, at least every 20ms (50Hz), and ideally higher.
However, I found that the reading was limited to only below 10Hz, which is substantially lower than what I expect. I was trying to change the "ScansAvailableFcnCount", but it does not increase the reading frequency any higher.
I have tried different devices on different computers, and the result all looks similar.
I was also looking into the function that was shipped with MATLAB "DataAcquisition.m", and it does seem like the rate was limited in line 1514. Is this expected? How can I increase the reading rate?

Best Answer

The Data Acquisition Toolbox in the MATLAB R2020b version does limit the data reading rate to 10Hz. This is expected behavior. 
The reason for doing this is when the user has more than 10 callbacks in a second (10Hz) in "DataAcquisition" object to read data from external hardware, the callbacks can stack in the buffer, and not execute due to hardware limitations. This limited rate is a safety feature to make sure that the users do not accidentally stack the callbacks, and think they are reading the current data.
In addition, the "ScansAvailableFcnCount" in the DataAcquisition object does not control the actual sample rate of the session, instead, it only controls how often the callback "ScansAvailableFcn" occurs (Rate that MATLAB reads data from device buffer).
It is possible to modify line 1514 in "DataAcquisition.m" to get a higher reading rate, but we strongly recommend the user not doing it, as it may result in unpredictable issues.