简体   繁体   中英

Import data from excel to matlab row by row


I need to know if there is any function that can import data from excel row by row?
I used to work with xlsread but it won't work for this case unless i use it in a function that takes all the columns and group all the element in the same row together...


Edit: I was able to do it using simple xlsread by the following code:

num = xlsread(excel_file,'B2:BI174');
row1=num(1:173:end);

Read xlsread documentation here to read a block from excel file.

Example: To read the first row from 1st to 26th coulmn use,

row1 = xlsread('filename.xlsx',sheet_no,'A1:Z1');

It is tempting to read the data one row at a time, but that means you will waste time due to file access overhead. It's a lot faster to read all at once and re-pack into a cell array:

allData = xlsread('filename.xls');

oneRowPerElementCell = mat2cell(allData, ones(size(allData,1),1), size(allData,2));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM