How to read units on a 2nd row out of an Excel file?
조회 수: 38 (최근 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!