23.06.2015 Views

MATLAB Programming

MATLAB Programming

MATLAB Programming

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

6 Data Import and Export<br />

Exchanging Files over the Internet<br />

<strong>MATLAB</strong> provides functions for exchanging files over the Internet. You can<br />

exchange files using common protocols, such as File Transfer Protocol (FTP),<br />

Simple Mail Transport Protocol (SMTP), and HyperText Transfer Protocol<br />

(HTTP). In addition, you can create zip archives to minimize the transmitted<br />

file size, and you can save and work with Web pages.<br />

For more information, see the following sections:<br />

• “Downloading Web Content and Files” on page 6-116<br />

• “Creating and Decompressing Zip Archives” on page 6-118<br />

• “Sending E-Mail” on page 6-119<br />

• “Performing FTP File Operations” on page 6-121<br />

Downloading Web Content and Files<br />

<strong>MATLAB</strong> provides two functions for downloading Web pages and files using<br />

HTTP: urlread and urlwrite. Withthe urlread function, you can read<br />

and save the contents of a Web page to a string variable in the <strong>MATLAB</strong><br />

workspace. With the urlwrite function, you can save a Web page’s content<br />

to a file.<br />

Because it creates a string variable in the workspace, the urlread function is<br />

useful for working with the contents of Web pages in <strong>MATLAB</strong>. The urlwrite<br />

function is useful for saving Web pages to a local directory.<br />

Note When using urlread, remember that only the HTML in that specific<br />

Web page is retrieved. The hyperlink targets, images, and so on will not be<br />

retrieved.<br />

If you need to pass parameters to a Web page, the urlread and urlwrite<br />

functions let you use HTTP post and get methods. For more information, see<br />

the urlread and urlwrite reference pages.<br />

6-116

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

Saved successfully!

Ooh no, something went wrong!