23.06.2015 Views

MATLAB Programming

MATLAB Programming

MATLAB Programming

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

6 Data Import and Export<br />

For example, you can create an FTP object for the public MathWorks FTP<br />

server with tmw=ftp('ftp.mathworks.com').<br />

2 Perform the file operations using appropriate <strong>MATLAB</strong> FTP functions as<br />

methods acting on the server object.<br />

For example, you can display the file directories on the FTP server with<br />

dir(tmw).<br />

3 When you finish working on the server, close the connection object using<br />

the close function.<br />

For example, you can disconnect from the FTP server with close(tmw).<br />

Example — Retrieving a File from an FTP Server<br />

In this example, you retrieve the file pub/pentium/Moler_1.txt, which is on<br />

the MathWorks FTP server. You can run this example; the FTP server and<br />

content are valid.<br />

1 Connect to the MathWorks FTP server using ftp. This creates the server<br />

object tmw:<br />

tmw=ftp('ftp.mathworks.com');<br />

2 List the contents of the server using the dir FTP function, which operates<br />

on the server object tmw:<br />

dir(tmw)<br />

3 Change to the pub directory by using the FTP cd function. As with all FTP<br />

functions, you need to specify the server object you created using ftp as<br />

part of the syntax. In this case, this is tmw:<br />

cd(tmw,'pub');<br />

The server object tmw represents the current directory on the FTP server,<br />

which now is pub.<br />

4 Now when you run<br />

dir(tmw)<br />

6-122

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!