MATLAB: How to import mixed .txt – file in a table, with text as comment on first 3 rows and then numeric data with headers

data importMATLABtable

I look for a method how to impor data from txt file, which contains at first position important comment information and then a regular nummeric table.
I would also like to set a fixed width for cells containing a comment so that it is fully visible.
I will be very grateful for any information on solving the problem!

Best Answer

Make it a two-step process!
First, read the first comment lines using FOPEN and FGETL. See the help of FGETL for an example. Do not forget to close the file with FCLOSE.
Two, read the rest of the file with READTABLE and use the HeaderLines option to skip the first comment lines.