I have an Excel sheet with headers of different depths and the numbers are not being read (ex.: d=-12.82m is being read as x_12_82M),
1 次查看(过去 30 天)
显示 更早的评论
I am trying to convert from Excel to a different format, for different depths but the headers are not being read properly.
I even tried changing it manually in Excel but if I do, they will be read as part of the data and not as headers
1 个评论
采纳的回答
Chunru
2023-11-20
% The first row is treated as var names. Use preserve to keep the original
% format
a = readtable("https://www.mathworks.com/matlabcentral/answers/uploaded_files/1544212/Sample.xlsx", "VariableNamingRule", "preserve")
s = a.Properties.VariableNames; % get the variable names
whos
d = cellfun(@(x) sscanf(x, "%f"), s(2:end) ) % convert to depth
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!