Open files with for loop with character as title
이전 댓글 표시
Hi,
I have a bunch of files to open and they are classed by month. Usually I would use a for loop and num2str to convert numbered month to string to read them, however the months are written in characters (AUGUST, MAY, etc)
Anyone knows how to solve this issue without changing the name of the files one by one?
Thanks in advance!
채택된 답변
추가 답변 (1개)
bym
2011년 8월 15일
something like this?
fileInfo = dir('*.csv'); % csv files in directory
numFile = length(fileInfo);
rawData = cell(1,numFile);
for i = 1:numFile
fid = fopen(fileInfo(i).name);
rawData{i} = textscan(fid,'%*s%*s%*s%s%*s%f','delimiter',',');
fclose(fid);
end
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!