frewind
열려 있는 파일의 시작 부분으로 파일 위치 포인터 이동
설명
예제
파일 위치 표시자 재설정
다음 파일을 열고 읽기 작업을 수행한 후 파일 위치 표시자를 다시 파일의 시작 부분으로 이동합니다.
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
행을 반환합니다.
tline3 = fgetl(fid)
tline3 = 'Orangutans and monkeys,'
파일의 첫 번째 줄을 다시 읽으면서 frewind
함수를 사용하여 위치 표시자를 재설정한 다음, 읽기 작업을 수행합니다.
frewind(fid) fgetl(fid)
ans = 'Oranges and lemons,'
파일을 닫습니다.
fclose(fid);
입력 인수
팁
파일이 테이프 장치에 있으며 되감기 작업이 실패하는 경우 frewind
는 오류 메시지를 반환하지 않습니다.
대안
frewind(fileID)
는 다음과 동일합니다.
fseek(fileID, 0, 'bof');
확장 기능
C/C++ 코드 생성
MATLAB® Coder™를 사용하여 C 코드나 C++ 코드를 생성할 수 있습니다.
스레드 기반 환경
MATLAB®의 backgroundPool
을 사용해 백그라운드에서 코드를 실행하거나 Parallel Computing Toolbox™의 ThreadPool
을 사용해 코드 실행 속도를 높일 수 있습니다.
이 함수는 스레드 기반 환경을 완전히 지원합니다. 자세한 내용은 스레드 기반 환경에서 MATLAB 함수 실행하기 항목을 참조하십시오.
버전 내역
R2006a 이전에 개발됨R2022b: 스레드 기반 환경에서 함수 사용
이 함수는 스레드 기반 환경을 지원합니다.
MATLAB 명령
다음 MATLAB 명령에 해당하는 링크를 클릭했습니다.
명령을 실행하려면 MATLAB 명령 창에 입력하십시오. 웹 브라우저는 MATLAB 명령을 지원하지 않습니다.
Select a Web Site
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:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)