How to import data from excel file as structure into Matlab?
35 次查看(过去 30 天)
显示 更早的评论
Hello, I have a relatively straight forward problem:
I have an excel sheet with two columns. The first column contains names and the second column contains numeric values. How can I import this file as a struct, so that I can access the values simply by their name?
2 个评论
采纳的回答
Walter Roberson
2020-10-30
T = readtable(TheFileName);
TC = table2cell(T);
TS = cell2struct(TC(:,2), TC(:,1), 1);
TS will now be a cell with field names according to the first column of the file and numeric value according to the second column of the file.
4 个评论
vishal kulkarni
2022-4-19
If column has special charcater in it, it fails.
Like,
Param1.Field1 -> this will fail
Walter Roberson
2022-4-19
编辑:Walter Roberson
2022-4-19
User indicated that the second columns are all numeric scalars.
更多回答(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!