Data import from excel file with timestamp
古いコメントを表示
Hi, I have an excel sheet with around 20 columns. I want to import the first 6 columns, with the first column that has a timestamp (date & time). The problem is that when I write the below code, the only data that is imported is from column B till F (instead from A till F as per code).
Data_Input = xlsread ('file.xlsx',"F:F")
Finally, is it possible that I import columns A and F only (therefore eliminating from B to E)?
Best Regards
4 件のコメント
Mohammad Sami
2020 年 1 月 9 日
Can you try using readtable and detectImportOption if you have the > R2016b
Stefan Azzopardi
2020 年 1 月 9 日
Stefan Azzopardi
2020 年 1 月 9 日
Mohammad Sami
2020 年 1 月 10 日
編集済み: Mohammad Sami
2020 年 1 月 10 日
After the detectImportOptions, you can change the following property
See documentation of spreadsheetImportOptions for more details
https://www.mathworks.com/help/releases/R2017b/matlab/ref/spreadsheetimportoptions.html?s_tid=doc_ta
Excerpt from documentation
SelectedVariableNames — Subset of variables to import
character vector | string scalar | cell array of character vectors | string array | array of numeric indices
Subset of variables to import, specified as a character vector, string scalar, cell array of character vectors, string array or an array of numeric indices.
SelectedVariableNames must be a subset of names contained in the VariableNames property. By default, SelectedVariableNames contains all the variable names from the VariableNames property, which means that all variables are imported.
Use the SelectedVariableNames property to import only the variables of interest. Specify a subset of variables using the SelectedVariableNames property and use readtable to import only that subset.
To support invalid MATLAB identifiers as variable names, such as varible names containing spaces and non-ASCII characters, set the PreserveVariableNames parameter to true.
Example: opts.SelectedVariableNames = {'Height','LastName'} selects only two variables, Height and LastName, for the import operation.
Example: opts.SelectedVariableNames = [1 5] selects only two variables, the first variable and the fifth variable, for the import operation.
Example: T = readtable(filename,opts) returns a table containing only the variables specified in the SelectedVariableNames property of the opts object.
Data Types: uint16 | uint32 | uint64 | char | string | cell
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Spreadsheets についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

