ドキュメンテーションヘルプ センター
最新のリリースでは、このページがまだ翻訳されていません。 このページの最新版は英語でご覧になれます。
開いている 1 つまたはすべてのファイルを閉じる
fclose(fileID)
fclose('all')
status = fclose(___)
例
fclose(fileID) は開いている 1 つのファイルを閉じます。
fileID
fclose('all') は、開いているすべてのファイルを閉じます。
status = fclose(___) は、閉じる操作が正常に完了した場合に 0 として status を返します。その他の場合は -1 を返します。この構文では、前述の構文の入力引数のいずれかを使用できます。
0
status
-1
すべて折りたたむ
badpoem.txt ファイルを開き、最初の行を読み取ってからファイルを閉じます。
badpoem.txt
fopen を使用してファイルを開きます。この関数は、ファイルの読み取りと書き込みに使用する一意のファイル識別子を割り当てます。
fopen
fid = fopen('badpoem.txt')
fid = 3
fgetl を使用してファイルから最初の行を読み取ります。
fgetl
fgetl(fid)
ans = 'Oranges and lemons,'
ファイルを閉じます。
fclose(fid);
開いているファイルのファイル識別子。整数として指定します。fclose でファイルを閉じる前に、fopen を使用してファイルを開き、fileID を取得しなければなりません。
fclose
データ型: double
double
feof | ferror | fopen | fprintf | fread | frewind | fscanf | fseek | ftell | fwrite
feof
ferror
fprintf
fread
frewind
fscanf
fseek
ftell
fwrite
この例の変更されたバージョンがシステム上にあります。代わりにこのバージョンを開きますか?
次の MATLAB コマンドに対応するリンクがクリックされました。
コマンドを MATLAB コマンド ウィンドウに入力して実行してください。Web ブラウザーは 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