ascii
FTP 転送モードを ASCII に設定
説明
例
転送モードを ASCII に設定
ASCII 転送モードを使用して、FTP サーバーからテキスト ファイルをダウンロードします。
まず、National Centers for Environmental Information (NCEI、米国環境情報センター) の FTP サーバーに接続します。
ftpobj = ftp('ftp.ngdc.noaa.gov')
FTP with properties: Host: "ftp.ngdc.noaa.gov" Username: "anonymous" Port: 21 ServerLocale: "en_US" DirParserFcn: @matlab.io.ftp.parseDirListingForUnix Mode: "binary" LocalDataConnectionMethod: "passive" RemoteWorkingDirectory: "/"
既定の転送モードはバイナリです。テキスト ファイルをダウンロードする場合、代わりに ASCII モードを使用できます。これにより改行文字が正しく変換されます。
転送モードを ASCII に設定します。現在の転送モードを表示するために、FTP オブジェクトを表示します。
ascii(ftpobj) ftpobj
FTP with properties: Host: "ftp.ngdc.noaa.gov" Username: "anonymous" Port: 21 ServerLocale: "en_US" DirParserFcn: @matlab.io.ftp.parseDirListingForUnix Mode: "ascii" LocalDataConnectionMethod: "passive" RemoteWorkingDirectory: "/"
テキスト ファイルをダウンロードして接続を切断します。
mget(ftpobj,'README.txt');
close(ftpobj)
README.txt
の先頭を表示します。コンピューターにダウンロードした README.txt
のコピーを読み取るには、関数 fileread
を使用します。
readme = fileread('README.txt');
readme(1:95)
ans = ' Welcome to the NOAA/National Centers for Environmental Information (NCEI)'
FTP サービスは National Centers for Environmental Information (NCEI、米国環境情報センター) により提供されています。NCEI の利用規約は、NCEI Privacy Policy, Disclaimer, and Copyright を参照してください。
入力引数
ftpobj
— FTP サーバーへの接続
FTP オブジェクト
FTP サーバーへの接続。FTP オブジェクトとして指定します。
バージョン履歴
R2006a より前に導入
MATLAB コマンド
次の MATLAB コマンドに対応するリンクがクリックされました。
コマンドを MATLAB コマンド ウィンドウに入力して実行してください。Web ブラウザーは 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)