
598 Accelerating MATLAB
®
Performance
11.3.2 Text File Pre-Processing
In some cases, we may wish to pre-process a textual data le so that we could more-easily
use functions such as textscan to parse the data. In almost all cases, the fastest way to do
this is to read the entire le into MATLAB memory as a long string, preprocess this string
using strrep and regexprep,* and then pass the resulting string to textscan for parsing.
This is preferable to externally pre-processing the le.
For example, to process a space-delimited text le as CSV, we might be tempted to pre-
process it with an external utility such as perl (bundled with MATLAB
†
):
16