This should be trivial, but I can’t find the answer in the MATLAB documentation. I have a TSV file consisting of ~60,000 rows and 38 columns. The first row has the names of the columns, and the first column consists entirely of alphanumeric strings. The remaining entries are all floating-point numbers (although, in many cases the value is expressed as just 0, without an explicit decimal point).
How can I read this data into MATLAB?
MATLAB provides a function
textscanfor this purpose. The second argument is the format specifier. In your case, the first field is a string, so we use%s, the remaining fields are float values, so we use%f. You will need 37 repeats of%f– a few more than in this example:HeaderLinestellstextscanhow many lines to skip before starting. You mention that the first line in your file contains the column names, so we skip1line.