Perform FTP File Operations

From MATLAB®, you can connect to an FTP server to perform remote file operations. The following procedure uses a public MathWorks® FTP server (ftp.mathworks.com). To perform any file operation on an FTP server, follow these steps:

  1. Connect to the server using the ftp function.

  2. Perform file operations using appropriate MATLAB FTP functions. For all operations, specify the server object.

  3. When you finish working on the server, close the connection object using the close function.

Example — Retrieve a File from an FTP Server

List the contents of the MathWorks FTP server and retrieve a file named README To view the file, use the type function.

tmw = ftp('ftp.mathworks.com');
dir(tmw)

mget(tmw,'README');
type README
Welcome to the MathWorks FTP site! 
The MathWorks FTP site has a new structure:

  /incoming - where you upload files to
  /outgoing - where you pick up files from

NOTE: Files in the above directories will be removed after 30 days.

You may also want to visit the MathWorks Web site at 

http://www.mathworks.com

Send questions/comments/suggestions to ftpadmin@mathworks.com

View the contents of the pub folder:

cd(tmw,'pub')
dir(tmw)

% Close the connection
close(tmw)

See Also

Was this topic helpful?