How to read units on a 2nd row out of an Excel file?
31 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Leon
am 16 Jun. 2020
Kommentiert: Leon
am 17 Jun. 2020
Attached is an example Excel file.
I'm using this command to read the info out of the file:
T1 = readtable('test.xlsx', 'PreserveVariableNames',true);
Here is my question. How do I read the units out of the 2nd row?
Thanks!
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 17 Jun. 2020
filename = 'test.xlxs';
opt = detectImportOptions(filename);
opt.VariableUnitsRange = '2:2'; %row number
T1 = readtable(filename, opt);
T1.Properties.VariableUnits will be set.
4 Kommentare
Walter Roberson
am 17 Jun. 2020
you cannot mix named options with the option structure. There is a field you can set in opt to preserve variable names but I would need to to look up the proper name.
Weitere Antworten (1)
Ameer Hamza
am 17 Jun. 2020
Try this
units = readtable('test.xlsx', 'Range', 'B2:D2', 'ReadVariableNames', false);
Siehe auch
Kategorien
Mehr zu Spreadsheets finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!