>> save filenamewhich results in all variables in use being saved in the file with the name `filename.mat'. The extension `.mat' does not necessary need to be given. If only a few variables need to be saved, these variable should be specified after the file name, e.g. only the variables
>> save filename x y
A saved `.mat' file can be read into MATLAB with the command
>> load filenamewhere the extension `.mat' can be omitted. The saved variables and their values are stored in the workspace and can now be used again.
loadcommand to read the entire content of the file in a single step. The
loadcommand requires that the data in the file is organized into a rectangular array. No column titles are permitted. One useful form of the load command is:
>> load measurements.txtwhere `measurements.txt' is the name of the file containing the data. The result of this operation is that the data in `measurements.txt' is stored in a variable called `measurements'. Files with various extension can be used. Note, that any extension except `.mat' indicates to MATLAB that the data is stored as plain ASCII text. A `.mat' extension is reserved for a file which has stored MATLAB variables.
>> load meas_xy.txt; % read data into the meas_xy variable >> x = meas_xy(:,1); % copy first column of my_xy into x >> y = meas_xy(:,2); % and second column into yAfter applying these commands, the data stored in column 1 of the text file is stored in the MATLAB variable