Improving speed of large interpolation (33 million to 33 billion elements)
5 views (last 30 days)
Show older comments
I am importing a bin file with ~33million elements and need to interpolate 1000 elements between the existing elements. As you can imagine, this isn't spedy and quickly consumes all the RAM on my machine. The code looks something like this.
data = fopen('ThirtyMillionElementFile.bin','r');
fclose('ThirtyMillionElementFile.bin');
data = interp(data,1000); %If I assign the interpolated value to a new variable such as...
% interpolatedData = interp(data,1000); the rest of the code breaks (seems related to memory issues).
filteredData = filter(importedFilterValues1, importedFilterValues2, data);
Overall this works but takes about 30 seconds. If I feed a larger file such as 66million elements and interp by 1000 the computer will completely lock up due to all 32 Gb of RAM and 100% of disk being used. Since I need to run larger files, how can I go about speeding this up and potentially improving the performance? In addition, I am not able to modify the filter in anyway. The whole idea is to use a legacy filter design.
I have found that tall arrays are not compatible with interp. And due to the 6 operations being done after interp and before the gather, tall arays will slow the code down to about an hour run time instead of 3 minutes total.
gpuArray doesn't help because I'm limited by 4Gb of Ram which will cause the code to error out.
I absolutely can and will add more RAM, but I am curious to know if there are other solutions that can be used in conjunction with increased hardware specs.
(Side Question: How is matlab able to store these massive arrays? There is no way I have enough RAM)
5 Comments
David Goodmanson
on 9 Jun 2020
Edited: David Goodmanson
on 9 Jun 2020
Hi David,
for the decimation do you mean
filteredData = filteredData(1:1000:length(filteredData)); ?
You have not mentioned the lengths of importedFilterValues1 and importedFilterValues2 but from the very fact that you have not done so, I am speculating that those lengths are reasonable, much less than the size of data and data1 and fit into memory with no problem. Assuming that is the case, since interp generally does not depend on data that is a long distance away in the array, and since the filter function can be done section by section, as can every other step that you show (with the help of a moderate sized buffer), is there any reason that you can't proceed section by section?
Answers (0)
See Also
Categories
Find more on Sources in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!