Import entire row instead of range from excel

5 ビュー (過去 30 日間)
Noa Hoogeweg
Noa Hoogeweg 2020 年 10 月 29 日
コメント済み: Noa Hoogeweg 2020 年 10 月 29 日
Hello!
Is there a way to import an entire row from excel in matlab?
So instead of:
[file] = xlsread(filename, 'Scans', 'A2:M2')
I want something like:
[file] = xlsread(filename, 'Scans', '2')
However, this of course doesn't work..
I can't use a range since the length of the row is unknown. (Of course it is not really unknown, but I want to analyze multiple excel data and not having to change the range every time).
Another important thing is: all rows have different sizes in my excel document, so using size(file) also doesn't work.
I hope someone can help me, thanks!

採用された回答

KSSV
KSSV 2020 年 10 月 29 日
T = readtable(file) ; % suggested
data = xlsread(file) ;
  2 件のコメント
Walter Roberson
Walter Roberson 2020 年 10 月 29 日
If you use readtable with a 'range' then
"Range must be of the form 'A1' (cell), 'A:B' (column-select), '1:5' (row-select), 'A1:B5' (rectangle-select), or a valid named range in the sheet."
So you could use 'range', '2' to get row 2. (You might perhaps need '2:2')
Noa Hoogeweg
Noa Hoogeweg 2020 年 10 月 29 日
Thanks! I did the following:
file = readtable(filename, 'Sheet', 'Scans')
file([2:2], :))
This worked and imported the entire row!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Import from MATLAB についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by