Excel Data import based on title cell.
5 次查看(过去 30 天)
显示 更早的评论
Hi folks, hope you are well.
I am wondering if anyone has a method of importing specific columns of data into MATLAB arrays based on the column title alone.
I am familiar with and have used the readvars/readtable functions extensively, however these have always required me to specify a range of column cells e.g. B:B for entire column B, C:C for entire column C etc. In my current work, I would like a method that reads column data straight from the excel sheet by locating this column by title alone, instead of me having to enter the sheet and find the specific letter column. E.g. if the column of data had a title 'Names' in cell C1, I would like the call to read and import all of the data in the C column, regardless of whether this was in C or another letter column entirely. The data I am working with has consistent title names in the '1' row, but columns are often in different orders - so any help with what I'm asking would be very efficient and help me massively.
Thanks!
C.
0 个评论
采纳的回答
Vilém Frynta
2023-3-21
After you read the table, you could simply search for the consistent names in your row. Then, you could specify which columns you are looking for, using those names.
For example, you could load all your data and then search the first row for a "Names", which would give you index (number) of that column. Then, you could use this index to load the whole column.
Does that make sense to you?
3 个评论
Vilém Frynta
2023-3-21
Great solution as well! If your issue has been resolved, and you think my answer has helped you, I would be happy if you could formally accept it.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Import from MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!