Even though the clock rate is 20 MHz, there is a timing overhead for each SPI transaction. This timing overhead is mainly caused by the vendor driver.
You can observe the duration for a transaction by opening NI IO Trace:
1. In Tools > Options > View Selections, select Duration as one of the columns
2. Start capture
Execute the code in MATLAB and compare the timing for each read function execution with the duration for ni845xSpiWriteRead driver function. This appears to be a limitation of the vendor's SPI Basic API which the MATLAB spi interface calls.
The vendor provides an SPI Stream API, which is probably a better option for reading data sent from the FLIR Lepton. However, the spi interface in Instrument Control Toolbox does not support calling the vendor's SPI Stream API functions.
To read more about the SPI Basic API vs the SPI Stream API, open help file for NI-845x vendor API "845xAPI.chm" located in C:\Users\Public\Documents\National Instruments\NI-845x\Documentation
NI-845x SPI Stream API is a C based API, so there might be a workaround possible by calling the NI-845x SPI Stream API functions from MATLAB by using the MATLAB external interfaces functionality. The vendor provides C code examples in "C:\Users\Public\Documents\National Instruments\NI-845x\Examples\MS Visual C\SPI\Stream". You can try converting it to MATLAB by using LOADLIBRARY/CALLLIB or MEX.
Best Answer