This preview shows pages 1–5. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Attia, John Okyere. “Plotting Commands.” Electronics and Circuit Analysis using MATLAB. Ed. John Okyere Attia Boca Raton: CRC Press LLC, 1999 © 1999 by CRC PRESS LLC CHAPTER TWO PLOTTING COMMANDS 2.1 GRAPH FUNCTIONS MATLAB has builtin functions that allow one to generate bar charts, xy, polar, contour and 3D plots, and bar charts. MATLAB also allows one to give titles to graphs, label the x and yaxes, and add a grid to graphs. In addition, there are commands for controlling the screen and scaling. Table 2.1 shows a list of MATLAB builtin graph functions. One can use MATLAB’s help facility to get more information on the graph functions. Table 2.1 Plotting Functions FUNCTION DESRIPTION axis freezes the axis limits bar plots bar chart contour performs contour plots ginput puts crosshair input from mouse grid adds grid to a plot gtext does mouse positioned text histogram gives histogram bar graph hold holds plot (for overlaying other plots) loglog does log versus log plot mesh performs 3D mesh plot meshdom domain for 3D mesh plot pause wait between plots plot performs linear xy plot polar performs polar plot semilogx does semilog xy plot (xaxis logarithmic) semilogy does semilog xy plot (yaxis logarithmic) shg shows graph screen stairs performs stairstep graph text positions text at a specified location on graph title used to put title on graph xlabel labels xaxis ylabel labels yaxis © 1999 CRC Press LLC © 1999 CRC Press LLC 2.2 XY PLOTS AND ANNOTATIONS The plot command generates a linear xy plot. There are three variations of the plot command. (a) plot(x) (b) plot(x, y) (c) plot(x1, y1, x2, y2, x3, y3, ..., xn, yn) If x is a vector, the command plot(x) will produce a linear plot of the elements in the vector x as a function of the index of the elements in x. MATLAB will connect the points by straight lines. If x is a matrix, each column will be plotted as a separate curve on the same graph. For example, if x = [ 0 3.7 6.1 6.4 5.8 3.9 ]; then, plot(x) results in the graph shown in Figure 2.1 . If x and y are vectors of the same length, then the command plot(x, y) plots the elements of x (xaxis) versus the elements of y (yaxis). For example, the MATLAB commands t = 0:0.5:4; y = 6*exp(2*t); plot(t,y) will plot the function y t e t ( ) = − 6 2 at the following times: 0, 0.5, 1.0, …, 4 . The plot is shown in Figure 2.2 . To plot multiple curves on a single graph, one can use the plot command with multiple arguments, such as plot(x1, y1, x2, y2, x3, y3, ..., xn, yn) © 1999 CRC Press LLC © 1999 CRC Press LLC Figure 2.1 Graph of a Row Vector x The variables x1, y1, x2, y2, etc., are pairs of vector. Each xy pair is graphed, generating multiple lines on the plot. The above plot command allows vectors of different lengths to be displayed on the same graph....
View
Full
Document
This note was uploaded on 12/19/2009 for the course ELECTRONIC elm 461 taught by Professor Oğuzkucur during the Spring '09 term at Gebze Institute of Technology.
 Spring '09
 Oğuzkucur

Click to edit the document details