Reading values corresponding to index
3 ビュー (過去 30 日間)
古いコメントを表示
Hi,
I am reading an excel xlsx file in MATLAB. I am reading the index from the file but also want to read the value in a column corresponding to that index. For example I am reading the index value 89792 but also want to read and display the corresponding value in column D highlighted in yellow.![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/524389/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/524389/image.png)
8 件のコメント
the cyclist
2021 年 2 月 21 日
I am hopeful that @Walter Roberson's answer below will help you figure it out. It's a good guess at the problem.
If not, maybe you could create a smaller version of your data file that shows the problem? For example, perhaps you could upload just the first few hundred rows of the Excel file, and code that tries to access an element.
回答 (1 件)
Walter Roberson
2021 年 2 月 21 日
Date_Time = T{89792,4}
is going to access row 89792 of the data table. That will not necessarily be the same as row 89792 of the .xlsx file. In particular, the rows that are considered to be headers will be skipped in the count.
If you cannot correct for that by subtracting the number of header lines from the indexing you use, then you should change from readtable() to readcell(), as readcell() will return all lines including headers.
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!