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 />

whos -file newstruct<br />

Name Size Bytes Class<br />

a 1x1 8 double array<br />

b 1x2 158 cell array<br />

c 1x6 12 char array<br />

Or save only selected fields using -struct and specifying each field name:<br />

save newstruct.mat -struct S a c;<br />

whos -file newstruct<br />

Name Size Bytes Class<br />

a 1x1 8 double array<br />

c 1x6 12 char array<br />

Appending to an Existing File<br />

You can add new variables to those already stored in an existing MAT-file by<br />

using save -append. When you append to a MAT-file, <strong>MATLAB</strong> first looks<br />

in the designated file for each variable name specified in the argument list,<br />

or for all variables if no specific variable names are specified. Based on that<br />

information, <strong>MATLAB</strong> does both of the following:<br />

• For each variable that already exists in the MAT-file, <strong>MATLAB</strong> overwrites<br />

its saved value with the new value taken from the workspace.<br />

• For each variable not found in the MAT-file, <strong>MATLAB</strong> adds that variable to<br />

the file and stores its value from the workspace.<br />

Note Saving with the -append option does not append additional elements to<br />

any arrays that are already saved in the MAT-file.<br />

6-25

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

Saved successfully!

Ooh no, something went wrong!