## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

No credit card required

Appendix B

# MATLAB’s Plotting Routines

This appendix lists the plotting routines in MATLAB with a brief description and example. To save space, some entries show a single encompassing example for multiple commands. An example may also use an ellipsis (...) to show the continuation of a pattern. To assist you, we have included several functions to generate test matrices, for example, rand(), magic(), peaks(), cylinder(), ellipsoid(), and sphere().

Table B-1 Basic Plotting Routines

 Routine Description Example ezplot Plots the expression enclosed in quotes ezplot('exp(-0.4*x)*sin(x)') fplot Same as ezplot, but requires limits fplot('exp(-0.4*x)*sin(x)',[0,2*pi,-0.3,0.6]) plot Plots data passed in by vectors x=[0:2*pi/100:2*pi]; y=exp(-0.4*x).*sin(x); plot(x,y); figure(2) comet(x,y); figure(3) ribbon(x,y);figure(4) y2=100*exp(-0.4*x).*cos(x); plotyy(x,y,x,y2) comet Just like plot, but comet animates the trajectory. It helps to have a larger vector to slow down the comet trace a tad ribbon Like plot, but it displays the data as 3D ribbons plotyy Plots data where y values may differ greatly — it makes two y-axes loglog Plots data on a log scale on both x- and y-axes — y proportional to a power of x is straight on this plot x=[0:2*pi/100:2*pi]; y=10*x.^pi; loglog(x,y) semilogx X-axis data is on a log scale and the y-axis is on a linear scale — y linearly related to log(x) is straight on this plot x=[0:2*pi/100:2*pi]; y=10*log(x)+pi; ...

## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

No credit card required