5_pdfsam_3 - data_1.mat Exporting and Importing Data There...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
c=6; x = -b/(2*a); y = sqrt(b^2-4*a*c)/(2*a); s1 = x+y s1 = -2 s2 = x-y s2 = -3 diary off Note that this is nearly the same as the display in the command window, with the exception that the Matlab prompt ( >> ) is not included. 3.2.2 Saving and Retrieving Matlab Variables There will be occasions when you want to save your Matlab variables so that you can later retrieve them to continue your work. In this case, you must save the information in the Matlab binary format, so that the full precision of the variables is retained. Files in this Matlab binary format are known as MAT-±les and they have an extension of mat . Storing and Loading Workspace Values save Stores workspace values (variable names, sizes, and values), in the binary ±le matlab.mat in the present working directory save data Stores all workspace values in the ±le data.mat save data 1xy Stores only the variables x and y in the ±le data_1.mat load data 1 Loads the values of the workspace values previously stored in the ±le
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: data_1.mat Exporting and Importing Data There are also situations in which you wish to export Matlab data to be operated upon with other programs, or to import data created by other programs. This must be done with text ±les written with save or read with load . To write a text ±le data1.dat in the current working directory containing values of Matlab variables in long e format: save data1.dat -ascii Note that the individual variables will not be identi±ed with labels or separated in any way. Thus, if you have de±ned variables a and b in the Matlab workspace, the command above will output ±rst the values in a , then the values in b , with nothing separating them. Thus, it is often desirable to write text ±les containing the values of only a single variable, such as: 41...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online