Help: xlsread with dynamic range of rows?
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi all,
How can I read an excel with unlimited dynamic range of rows? Just stop at the row which has NaN values. I attached my code to make easier for you to understand my problem. It doesn't work, just decribe my question.
n=1000; (maximum number of rows_how could I set it unlimited?)
for i=1:n
range=sprintf('A%d',i);
[num,text,raw]=xlsread('c:\text.xlsx',1,range);
if raw(i,1)==[NaN]
break (break the for-loop)
end
end
result=i-1; (number of rows which doesn't inclued NaN value)
For example: with the following picture, the script will stop at the 22nd row and the result variable will be 21
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/145624/image.png)
댓글 수: 0
답변 (1개)
Guillaume
2014년 10월 7일
Simply do not specify a range when you call xlsread:
[num, text, raw] = xlsread('c:\text.xlsx', 1);
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!