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.

Saving and Loading MAT-Files<br />

• Each variable to be saved must be either a two-dimensional double array<br />

or a two-dimensional character array. Saving a complex double array<br />

causestheimaginarypartofthedatatobelost,as<strong>MATLAB</strong>cannotload<br />

nonnumeric data ('i').<br />

• Toreadthefilewiththe<strong>MATLAB</strong>load function, make sure all the<br />

variables have the same number of columns. If you are using a program<br />

other than <strong>MATLAB</strong> to read the saved data, this restriction can be relaxed.<br />

• Each <strong>MATLAB</strong> character in a character array is converted to a<br />

floating-point number equal to its internal ASCII code and written out as a<br />

floating-point number string. There is no information in the saved file that<br />

indicates whether the value was originally a number or a character.<br />

• The values of all variables saved merge into a single variable that takes<br />

thenameoftheASCIIfile(minusanyextension). Therefore, it is advisable<br />

to save only one variable at a time.<br />

Saving in Version 4 Format. With the -v4 option, you can save only those<br />

data constructs that are compatible with <strong>MATLAB</strong> Version 4. Therefore,<br />

you cannot save structures, cell arrays, multidimensional arrays, or objects.<br />

Variable names cannot exceed 19 characters in length. In addition, you must<br />

use filenames that are supported by <strong>MATLAB</strong> Version 4.<br />

Storage Requirements<br />

The binary formats used by save depend on the size and type of each array.<br />

Arrays with any noninteger entries and arrays with 10,000 or fewer elements<br />

are saved in floating-point formats requiring 8 bytes per real element. Arrays<br />

with all integer entries and more than 10,000 elements are saved in the<br />

formats shown, requiring fewer bytes per element.<br />

Element Range<br />

0 to 255 1<br />

0 to 65535 2<br />

-32767 to 32767 2<br />

-2 31 to 2 31 -1 4<br />

Other 8<br />

Bytes per Element<br />

6-29

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

Saved successfully!

Ooh no, something went wrong!