in black and white
Main menu
Home About us Share a book
Biology Business Chemistry Computers Culture Economics Fiction Games Guide History Management Mathematical Medicine Mental Fitnes Physics Psychology Scince Sport Technics

A Guide to MATLAB for Beginners and Experienced Users - Brian R.H.

Brian R.H., Roland L.L. A Guide to MATLAB for Beginners and Experienced Users - Cambrige, 2001. - 346 p.
Download (direct link): beginnersandex2001.pdf
Previous << 1 .. 79 80 81 82 83 84 < 85 > 86 87 88 89 90 .. 91 >> Next

sum Sums a vector, or sums the columns of a matrix.

k = 1:10; sum(k) sym Creates a symbolic variable or number.

sym pi x = sym('x') constant = sym('1/2')

syms Shortcut for creating symbolic variables. The command syms x is equivalent to x = sym('x').

syms x y z Glossary 309

symsum Performs a symbolic summation of a vector, possibly with infinitely many entries.

syms x k n; symsum(x~k, k, 0, n) syms n; symsum(n"(-2), n, 1, Inf)

taylor Gives a Taylor polynomial approximation of a specified order (the default is 5) at a specified point (default is 0).

syms x; taylor(cos(x), 8, 0) taylor(exp(1/x), 10, Inf)

transpose Transpose of a matrix (compare ctranspose). Converts a column vector to a row vector, and vice versa. Usually invoked with the .' operator. A= [13 4] A.'

type Displays the contents of a specified file. type myfile.m

vectorize Vectorizes a symbolic expression. Useful in defining inline functions. f = inline(vectorize('x~2 - 1/x'))

vpa Evaluates an expression to the specified degree of accuracy using variable precision arithmetic. vpa('1/3', 20)

whos Lists current information on all the variables in the Workspace.

zeros Creates a matrix of zeros. zeros(10) zeros(3, 1)

Graphics Commands

area Produces a shaded graph of the area between the x axis and a curve.

X = 0:0.1:4*pi; Y = sin(X); area(X, Y) axes Creates an empty figure window. axis Sets axis scaling and appearance.

axis([xmin xmax ymin ymax]) — sets ranges for the axes. axis tight —sets the axis limits to the full range of the data. axis equal —makes the horizontal and vertical scales equal. axis square — makes the axis box square. axis off — hides the axes and tick marks. 310 Glossary

bar Draws a bar graph. bar([2, 7, 1.5, 6])

cla Clear axes.

close Closes the current figure window; close all closes all figure windows.

colormap Sets the colormap features of the current figure; type help graph3d to see examples of colormaps.

X = 0:0.1:4*pi; Y = sin(X); colormap cool comet Displays an animated parametric plot.

t = 0:0.1:4*pi; comet(t.*cos(t), t.*sin(t))

contour Plots the level curves of a function of two variables; usually used with meshgrid.

[X, Y] = meshgrid(-3:0.1:3, -3:0.1:3); contour(X, Y, X.~2 - Y.~2)

contourf Filled contour plot. Often used with colormap.

[X,Y] = meshgrid(-2:0.1:2, -2:0.1:2); contourf(X, Y, X.~2 - Y.~3); colormap autumn

ezcontour Easy plot command for contour or level curves. ezcontour('x~2 - y~2') syms x y; ezcontour(x - y~2)

ezmesh Easy plot command for mesh view of surfaces. ezmesh('x~2 + y~2') syms x y; ezmesh(x*y)

ezplot Easy plot command for symbolic expressions.

ezplot('exp(-x~2)', [-5, 5]) syms x; ezplot(sin(x))

ezplot3 Easy plot command for 3D parametric curves. ezplot3('cos(t)', 'sin(t)', 't')

syms t; ezplot3(1 - cos(t), t - sin(t), t, [0 4*pi])

ezsurf Easy plot command for standard shaded view of surfaces. ezsurf('(x~2 + y~2)*exp(-(x~2 + y~2))') syms x y; ezsurf(sin(x*y), [-pi pi -pi pi])

figure Creates a new figure window.

fill Creates a filled polygon. See also patch.

fill([0 110], [0011], 'b'); axis equal tight Glossary 311

findobj Finds graphics objects with specified property values.

findobj('Type', 'Line') gca Gets current axes. gcf Gets current figure. get Gets properties of a figure. get(gcf)

getframe Command to get the frames of a movie or animation.

T = 0:0.1:2*pi; for j = 1:12

plot(5*cos(j*pi/6) + cos(T), 5*sin(j*pi/6) + sin(T)); axis([-6 6 -6 6]); M(j) = getframe;



ginput Gathers coordinates from a figure using the mouse (press the RETURN key to finish).

[X, Y] = ginput

grid Puts a grid on a figure.

gtext Places a text label using the mouse. gtext('Region of instability')

hist Draws a histogram.

for j = 1:100

Y(j) = rand;



hold Holds the current graph. Superimposes any new graphics generated by MATLAB on top of the current figure.

hold on hold off

legend Creates a legend for a figure.

t = 0:0.1:2*pi;

plot(t, cos(t), t, sin(t))

legend('cos(t)', 'sin(t)')

loglog Creates a log-log plot.

x = 0.0001:0.1:12; loglog(x, x.~5) 312 Glossary

mesh Draws a mesh surface.

[X,Y] = meshgrid(-2:.1:2, -2:.1:2); mesh(X, Y, sin(pi*X).*cos(pi*Y))

meshgrid Creates a vector array that can be used as input to a graphics command, for example, contour, quiver, or surf.

[X, Y] = meshgrid(0:0.1:1, 0:0.1:2) contour(X, Y, X.~2 + Y.~2)

movie Plays back a movie. See the entry for getframe.

patch Creates a filled polygon or colored surface patch. See also fill.

t = (0:1:5)*2*pi/5; patch(cos(t), sin(t), 'r'); axis equal pie Draws a pie plot of the data in the input vector. Z = [34 5 32 6]; pie(Z)

plot Plots vectors of data.

X= [0:0.1:2]; plot(X, X.~3)

plot3 Plots curves in 3D space. t = [0:0.1:30];

plot3(t, t.*cos(t), t.*sin(t))

polar Polar coordinate plot command.

theta = 0:0.1:2*pi; rho = theta; polar(theta, rho)
Previous << 1 .. 79 80 81 82 83 84 < 85 > 86 87 88 89 90 .. 91 >> Next