How can I read in rows from an Excel spreadsheet iteratively?

I am working with a spreadsheet too large to import into Matlab. Is there a way I can read in one row at a time in a for loop? I'm unsure how to increment inside of a char. Currently, this is what I have:
filename = 'data.xlsx.';
xlRange = 'A1:A1888';
dataS = xlsread(filename,xlRange);

답변 (4개)

sixwwwwww
sixwwwwww 2013년 10월 16일
Dear Jon, You can read excel file iteratively using for loop as follows:
count = 1;
n = 1888;
increment = 10;
for i = 1:increment:n
num{count} = xlsread('filename.xlsx', strcat('A',num2str(i),':A',num2str(i + increment - 1)));
count = count + 1;
end
I hope it helps. Good luck!

댓글 수: 1

Image Analyst
Image Analyst 2013년 10월 16일
편집: Image Analyst 2013년 10월 18일
You've got to be kidding me. You suggest to call xlsread() 188 times? I hope he has all day to wait.

댓글을 달려면 로그인하십시오.

Jon
Jon 2013년 10월 16일

0 개 추천

Thank you for the quick response! I actually made a mistake in phrasing the question. The row #'s will always be 1:1888, I need the letters on the rows such as the A on A1 to increment. So I need the loop to read A1:A1888, next B1:B1888, C1:C1888 etc Thanks!

댓글 수: 1

Image Analyst
Image Analyst 2013년 10월 16일
편집: Image Analyst 2013년 10월 16일
No you don't. You can use R1C1 instead of A1 cell referencing. If you want to keep letters, then use Mike Sheppard's excelcol from the File Exchange. Don't miss my Answer elsewhere here.

댓글을 달려면 로그인하십시오.

Jon
Jon 2013년 10월 16일

0 개 추천

Also my columns go up to 3 letter column designations, not sure how to handle that either
Image Analyst
Image Analyst 2013년 10월 16일

0 개 추천

Yes, you can use ActiveX like we so often recommend here. There are lots of examples. I've attached one below. You definitely DO NOT want to use xlsread - I can't stress that enough, unless you want to wait an eternity for your process to finish.

댓글 수: 1

Jon - were you able to accomplish your task? What's the status of this?

댓글을 달려면 로그인하십시오.

카테고리

질문:

Jon
2013년 10월 16일

댓글:

2013년 10월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by