Is it possible to decide which line is variable names in readtable?
Show older comments
I want to use readtable to read data from an excel file. As I understand, in readtable, the first line is automatically the variable names. However, in my excel file, not just the first line, but the starting 3 lines contain characters and I want to know whether it is possible to use readtable to have an output where the vaiable names are the words that appear in the 3rd (or any desired) line.
A part of the excel file looks like this:

and I want the output to be like this:
ML125 MLCorr ML100 Ds
--------------------------------
32.2 32.2 48.44 15.2
...
Accepted Answer
More Answers (1)
Jeremy Hughes
on 24 Jun 2022
0 votes
You can try:
readtable(filename,"NumHeaderLines",2)
or
opts = detectImportOptions(filename)
opts.VariableNamesRange = "A3"
T = readtable(filename,opts)
Categories
Find more on Spreadsheets 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!