How can I process a sequence of EXCEL files inside a FOR loop
조회 수: 1 (최근 30일)
이전 댓글 표시
i have n numbers of excel files like this : mydata1.xlsx , mydata2.xlsx , mydata3.xlsx and so on . Now i want to process each of the excel file iteratively in a FOR loop . This is what , i have tried so far
for i =1:n
fprintf('Enter the Excel file name \n');
m=input('');
M= xlsread(m);
.
.
.
MY codes
.
.
end
But Its not working . Kindly help me . Thankx in advance.
댓글 수: 0
채택된 답변
Orion
2014년 10월 6일
Hi,
You need to do a loop like this :
for i = 1:n
% ask the user the name of excel file (without the extension)
XlsFile = input('Enter the Excel file name : ','s');
% Read the spredsheet by adding the _.xlsx_ string to the Xls filename
XlsData = xlsread([XlsFile '.xlsx']);
% then : code to process XlsData
end
You might consider to remove the input of the for loop and define your xls files before, otherwise the user has to be ready to write at each iteration, which can take a long time.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!