How to read an excel file row by row

21 ビュー (過去 30 日間)
Far mah
Far mah 2019 年 11 月 20 日
回答済み: Bhargavi Maganuru 2019 年 11 月 27 日
Hello
I need to read through an excel sheet (considering it a matrix) row by row. I would go by x=xlsread('filename.xls') a=x(1,:), b=x(2,:). but I have too many rows and file is pretty big and its not efficient.
lets say this is from excel file:
A B C D E F
1 9 2 3 4 5 6
2 6 4 5 6 6 6
3 2 3 4 5 6 6
How can I read the excel to get values like this: A1 (9), B1 (2), C1 (3), D1(4), E1 (5), F1(6) ,A2, B2, C2,...
these values are then going to be multiplied (in this order) in another statement .
Thank you for your help!
  1 件のコメント
Walter Roberson
Walter Roberson 2019 年 11 月 20 日
It is possible, but I would suggest you have a look at tall() arrays with a datastore() backing.

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

回答 (1 件)

Bhargavi Maganuru
Bhargavi Maganuru 2019 年 11 月 27 日
If you want to access elements row wise you can just use for loop.
for i=1:size(x,1)
for j=1:size(x,2)
% x(i,j) gives the order that you are expecting
end
end
If you want to read an excel file with column names you could use reabtable instead of xlsread.
xlsread is not recommended.Use readtable, readmatrix or readcell instead.For more information you can refer to the follwing link

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by