I need to read a file and store the values, so I can call these values in a for loop.
    조회 수: 7 (최근 30일)
  
       이전 댓글 표시
    
I have a file (names.txt) that is a list of file names. There is one file name per line. I need to read that file, so that each file name can be used in a for loop. I've tried to read the file as multiple strings with fscanf, but I get all the file names concatenated into one single string. How can I read the file into a single column array?
댓글 수: 0
채택된 답변
  KSSV
      
      
 2017년 2월 28일
        fid = fopen('your txt file') ;
S = textscan(fid,'%s','delimiter','\n') ;
S = S{1} ;
fclose(fid) ;
for i = 1:length(S)
    S{i}
end
댓글 수: 0
추가 답변 (1개)
참고 항목
카테고리
				Help Center 및 File Exchange에서 Workspace Variables and MAT Files에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

