Graphics Reference
In-Depth Information
plot (X, Y, S) draws plot(X,Y) with the settings defined in S . Usually, S consists of two
symbols between single quotes, the first of which sets the color of the line of the graph, and
the second sets the character to be used in the plotting. The possible values of colors and
characters are, respectively, as follows:
y yellow . Point marker
m magenta o Circle marker
c cyan x X marker
r Red + Plus signs
g green - Solid line
b Blue * Star marker
w White : Dotted line
k Black -. Dashes and dots
- Dashed line
plot(X1,Y1,S1,X2,Y2,S2,X3,Y3,S3,…) combines, on the same axes, graphs defined for the
triplets (Xi, Yi, Si). It is a way of representing various functions on the same graph.
fplot(function, [xmin, x max]) graphs the function for the variation of x over the
given range.
fplot(function, [xmin, x max, ymin, ymax], S) graphs the function over the range xmin
to xmax while limiting the y-axis to the range of ymin to ymax, with options for color, line
style, and markers given by S.
fplot([f1,f2,…,fn],[xmin, x max, ymin, ymax], S) graphs functions f1, f2,…, fn on the same
axes at intervals for the range of x and y specified, and the color, line, and marker styles
defined in S.
ezplot ('expression, [xmin x max]) graphs the expression for the variation of x given in the
range.
Let's see some examples of 2-dimensional graphics:
We will begin by representing the function f (x) = (sin(x)) ^ 2 + 2xcos(x) (-2,2) :
>> x = [-2*pi:0.1:2*pi];
>> y = sin(x) .^ 2 + 2 * x .* cos(x);
>> plot(x,y)
MATLAB returns the graph that is shown in Figure 2-1 . It is worth noting that the definition of the function has
been made in vector form, using the notation for vector variables. The range of the trigonometric function is defined
in pi radian (in this case -2 pi to 2 pi).
Search WWH ::




Custom Search