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.

Saving and Loading MAT-Files<br />

Saving and Loading MAT-Files<br />

This section explains how to save the variables in your <strong>MATLAB</strong> session to a<br />

binary file called a MAT-file, and how to load them back into your <strong>MATLAB</strong><br />

workspace. It covers the following:<br />

• “Exporting Data to MAT-Files” on page 6-23<br />

• “Importing Data from MAT-Files” on page 6-30<br />

MAT-files are double-precision, binary, <strong>MATLAB</strong> format files. They can be<br />

created on one machine and later read by <strong>MATLAB</strong> on another machine with<br />

a different floating-point format, retaining as much accuracy and range as<br />

the different formats allow. They can also be manipulated by other programs<br />

external to <strong>MATLAB</strong>.<br />

Exporting Data to MAT-Files<br />

This section covers<br />

• “Using the save Function” on page 6-23<br />

• “Saving Structures” on page 6-24<br />

• “Appending to an Existing File” on page 6-25<br />

• “Data Compression” on page 6-26<br />

• “Unicode Character Encoding” on page 6-27<br />

• “Optional Output Formats” on page 6-28<br />

• “Storage Requirements” on page 6-29<br />

• “Saving from External Programs” on page 6-30<br />

Using the save Function<br />

To export workspace variables to a binary or ASCII file, use the save function.<br />

You can save all variables from the workspace in a single operation (if you<br />

omit the filename, <strong>MATLAB</strong> uses the name matlab.mat):<br />

save filename<br />

6-23

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

Saved successfully!

Ooh no, something went wrong!