12.07.2015 Views

Basics of MATLAB and Beyond

Basics of MATLAB and Beyond

Basics of MATLAB and Beyond

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

name>> staff(2,1,2).name(5:9)ans =Blogg30 Saving <strong>and</strong> Loading Data30.1 <strong>MATLAB</strong> Formatmatlab’s internal st<strong>and</strong>ard for saving <strong>and</strong> loading data is the mat-file.The save comm<strong>and</strong> saves all the variables in the workspace to a disk filecalled matlab.mat:>> a = 1;>> b = 1:10;>> str = ’hello’;>> saveSaving to: matlab.matTo save in a file with a different name, type:save saved_dataTo save only some <strong>of</strong> the variables, add their names:save saved_data a bMat-files are binary files whose format is described fully in the matlabdocumentation. Such a file is fully portable to matlab running onanother kind <strong>of</strong> computer. Information about the kind <strong>of</strong> computer thatmatlab was running on when it saved the data is stored along with thedata. When matlab reads in a mat-file, it checks the type <strong>of</strong> computerthat the data were saved on <strong>and</strong> automatically performs any requiredmanipulations (byte swapping, for example).To load data from mat-files use the load comm<strong>and</strong>:>> clear>> a = 1;>> b = 1:10;>> str = ’hello’;>> save saved_data>> clear>> whos>> load saved_datac○ 2000 by CRC Press LLC

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

Saved successfully!

Ooh no, something went wrong!