%% Download File to Specified Folder
% Download a text file from an FTP server to a specified folder on your local machine.
% First, connect to the National Centers for Environmental Information (NCEI) FTP server.

s = ftp('ftp.ngdc.noaa.gov')

%
% Download a text file to a folder named myLocalFolder. If this folder does not exist, then the mget function creates it on your local machine.

mget(s,'README.txt','myLocalFolder');

%
% Read the beginning of README.txt using the fileread function.

readme = fileread('myLocalFolder/README.txt');
readme(1:95)

%
% FTP service courtesy of the National Centers for Environmental Information (NCEI). See the NCEI Privacy Policy, Disclaimer, and Copyright for NCEI terms of service.
% Copyright 2012 The MathWorks, Inc.