Matlab basics I Flashcards
;
suppresses output of command
num2str
converts numbers to a string
disp
displays array without printing array name; can also display text
figure (x)
causes x to be new figure
whos
generates list of variables and arrays in current workspace
diary
diary filename: saves all typed commands into “filename”
diary off: suspends input into diary file
diary on: resumes input into diary file
size ( )
displays dimension of the array
x(1,:)
first row of x
x(:,1)
first column of x
plot
plot: automatically opens figure window
figure
manually opens figure window
plot(x)
vectors: plots x vs. its index
matrices: plots columns of x vs their indices
plot (x,y)
vectors: plots vector y vs. vector x
matrices: plots rows/columns y vs rows/columns x (whichever line up); generates multiple curves
plot(x1, y1, x2, y2)
plots two curves: y1 vs x1 and y2 vs x2
plot(x1,y1, ‘r-‘, x2, y2, ‘b–’)
plots y1 vs x1 with a red solid line
plots y2 vs x2 with a blue dashed line
title(‘string’)
adds a title to a figure
xlabel(‘string’)
ylabel(‘string’)
adds label to x axis
adds label to y axis
semilogx(x,y)
plots y vs x using log scale for x and linear scale for y
semilogy(x,y)
plots y vs x using linear scale for x and log scale for y
loglog(x,y)
plots y vs x using log scale for both axes
bar(x)
vector: generates a vertical bar graph of the vector x vs its element index
matrix: groups data by row and generates a group of vertical bars
pie (x)
generates a pie chart with every element in x represented by a slice of the pie
hist(x)
generates a histogram. computes and plots number of values of x falling into 10 bins (default) equally spaced between min and max values
.fig
matlab figure file, can only be opened in matlab
exports figure plots as graphic images
- deps: create encapsulated postscript image
- djpeg: create a JPEG image
- dtiff: creates a compressed TIFF image
- dpng: create a portable network graphic color image
single( )
specifies single precision floating point numbers