How to read units on a 2nd row out of an Excel file?
40 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
Walter Roberson
2020 年 6 月 17 日
filename = 'test.xlxs';
opt = detectImportOptions(filename);
opt.VariableUnitsRange = '2:2'; %row number
T1 = readtable(filename, opt);
T1.Properties.VariableUnits will be set.
4 件のコメント
Walter Roberson
2020 年 6 月 17 日
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.
その他の回答 (1 件)
Ameer Hamza
2020 年 6 月 17 日
Try this
units = readtable('test.xlsx', 'Range', 'B2:D2', 'ReadVariableNames', false);
参考
カテゴリ
Help Center および File Exchange で Spreadsheets についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!