0% found this document useful (0 votes)
49 views

1 Pawandeep Singh Bagga

The document discusses saving and loading variables and data in MATLAB. It explains that the save command can be used to save workspace variables to a .mat file, and the load command loads variables from a saved file. Specific variables can be loaded using their names. Wildcards can load variables matching a pattern. ASCII data files can be loaded into MATLAB, with the data placed in a variable of the same name as the file. Functions like csvread and dlmread can read delimited text files, while low-level I/O functions allow accessing other data formats.

Uploaded by

pawandeep
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views

1 Pawandeep Singh Bagga

The document discusses saving and loading variables and data in MATLAB. It explains that the save command can be used to save workspace variables to a .mat file, and the load command loads variables from a saved file. Specific variables can be loaded using their names. Wildcards can load variables matching a pattern. ASCII data files can be loaded into MATLAB, with the data placed in a variable of the same name as the file. Functions like csvread and dlmread can read delimited text files, while low-level I/O functions allow accessing other data formats.

Uploaded by

pawandeep
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

1

***********************Pawandeep Singh Bagga**************************


To save all the variables in the workspace onto disk use the save command. Typing save
keep file will save the workspace variables to a disk file called keep file.mat, a binary file
whose format is described in
the matlab documentation. This data can be loaded into matlab by typing load keepfile. To
save or load only certain variables, specify them after the filename.
For example, load keepfile x will load only the variable x from the saved file. The wild-card
character * can be used to save or load variables according to a pattern. For example, load
keepfile *_test loads only
the variables that end with _test. When the filename or the variable names are stored in
strings, you
can use the functional forms of these commands, for example:
save keepfile is the same as save (keepfile)
save keepfile x . . . save (keepfile,x)
load keepfile . . . A = keepfile
load (A)
A file containing a list or table of numbers in ASCII format can be loaded into matlab. The
variable containing the data is given the same name as the file name without the extension.
For example, if a file nums.dat contained ASCII data, load nums.dat would load the data into
a variable called nums. If the ASCII file contained a table of numbers, the variable would be
a matrix the same size as the table.
Other functions are available to read various forms of delimiter-separated text files:
csvread Read a comma separated value file
csvwrite Write a comma separated value file
dlmread Read ASCII delimited file
dlmwrite Write ASCII delimited file
Matlabs low-level input/output routines can be used to access more unusual data formats.
They are listed here for reference:
File Opening and Closing: fclose fopen
Unformatted I/O: fread fwrite
Formatted I/O: fget l fprintf
fgets fscanf
File Positioning: feof fseek
ferror ftell
frewind
String Conversion: sprintf sscanf

411067

You might also like