A HW device stores binary data on disk as an array of 32.5e6 unsigned short values which are then read into Matlab workspace, using either fread or memmapfile. The data is actually complex in nature, arranged as I/Q/I/Q/,,, Our goal is to convert the short values into a complex array so that we may perform FFT and other Matlab operations. The problem is that the conversions to single and then to complex are each very time consuming; please see below.
datasize = 32.5e6;
fileID = fopen('dataFile_uint16.bin', 'r');
temp = fread(fileID, dataSize, 'int16=>int16');
temp1 = single(temp);
complexArray = temp1(1:2:dataSize) + 1i*temp1(2:2:dataSize);
I have tried alternatives to the last line of code above such as complex(a,b) and reshape instead of indexing, but no real-time savings is noticed. Any suggestions?
A rigourous alternative is to write a mex-file which reads, converts, and returns the data to an mxComplexArray type. However, before enbarking on such a journey, I would like to know if the savings in real-time will justify the effort.