문서도움말 센터
이 페이지의 최신 내용은 아직 번역되지 않았습니다. 최신 내용은 영문으로 볼 수 있습니다.
열려 있는 파일의 시작 부분으로 파일 위치 표시자(File Position Indicator) 이동
frewind(fileID)
예제
frewind(fileID)는 파일 위치 표시자를 파일의 시작 부분으로 설정합니다.
fileID
모두 축소
다음 파일을 열고 읽기 작업을 수행한 후 파일 위치 표시자를 다시 파일의 시작 부분으로 이동합니다.
fopen을 사용하여 파일을 연 다음, fgetl을 사용하여 처음 두 줄을 읽습니다.
fopen
fgetl
fid = fopen('badpoem.txt'); tline1 = fgetl(fid) % read first line
tline1 = 'Oranges and lemons,'
tline2 = fgetl(fid) % read second line
tline2 = 'Pineapples and tea.'
앞의 두 읽기 작업으로 위치 표시자가 시의 3행 시작 부분으로 이동했습니다. 그 결과, fgetl 을 사용하는 다음 읽기 작업은 3행을 반환합니다.
3
tline3 = fgetl(fid)
tline3 = 'Orangutans and monkeys,'
파일의 첫 번째 행을 다시 읽는 방법. frewind 함수를 사용하여 위치 표시자를 재설정한 다음, 읽기 작업을 수행합니다.
frewind
frewind(fid) fgetl(fid)
ans = 'Oranges and lemons,'
파일을 닫습니다.
fclose(fid);
열려 있는 파일의 파일 ID로, 정수로 지정됩니다. frewind를 사용하기 전에 fopen을 사용하여 파일을 열고 파일의 fileID를 가져와야 합니다.
데이터형: double
double
파일이 테이프 장치에 있으며 되감기 작업이 실패하는 경우 frewind는 오류 메시지를 반환하지 않습니다.
frewind(fileID)는 다음과 동일합니다.
fseek(fileID, 0, 'bof');
fclose | feof | ferror | fopen | fprintf | fread | fscanf | fseek | ftell | fwrite
fclose
feof
ferror
fprintf
fread
fscanf
fseek
ftell
fwrite
귀하의 시스템에 이 예제의 수정된 버전이 있습니다. 이 버전을 대신 여시겠습니까?
다음 MATLAB 명령에 해당하는 링크를 클릭했습니다.
명령을 실행하려면 MATLAB 명령 창에 입력하십시오. 웹 브라우저는 MATLAB 명령을 지원하지 않습니다.
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office