Mat-Lab Lecture 3
Mat-Lab Lecture 3
Management
MATLAB can also import data from and export data to two
common formats that are used in spreadsheet and database
program formats. The more common of these file formats is the
comma separated values or .csv format. This is an ASCII text file,
with values on each line separated by commas, as the name
implies. The second format is the spreadsheet .wk1 format, often
used as an interchange format for different spreadsheet programs.
The MATLAB import and export commands for these formats are:
A = csvread(file)
Reads a comma separated value formatted
file file. The result is returned in A. The file can only contain
numeric values.
csvwrite(file,A)
Writes matrix A into file as comma
separated values.
A = wk1read(file) Reads all the data from a WK1 spreadsheet
file named file into matrix A.
wk1write(file,A)
Writes matrix A into a WK1 spreadsheet file
with the name file. .wk1 is appended to the filename if no
extension is given.
A= xlsread(file)
Xlswrite(file,A)
Programming Style
Matlab at Startup
Two files are executed at startup: matlabrc.m and startup.m
matlabrc.m: Comes with MATLAB, shouldnt be modified.
Sets default Figure window size and placement, as well as
a number of other default features.
startup.m: An optional M-file to be created by the user,
typically containing commands that add personal default
features. It is common to put addpath or path commands
in startup.m to append additional directories to the
MATLAB search path. Since startup.m is a standard script
M-file, then there are no restrictions as to what commands
can be placed in it. For example, you might want to include
the command format compact in startup.m so that the
compact results display format becomes the default.