15
plot (x-values, y- plot (x-values, y- values) values) >> x = linspace (-3, >> x = linspace (-3, 3, 20); 3, 20); >> y = 2*x – 1; >> y = 2*x – 1; >> plot (x, y) >> plot (x, y)

plot (x-values, y-values)

Embed Size (px)

DESCRIPTION

plot (x-values, y-values). >> x = linspace (-3, 3, 20); >> y = 2*x – 1; >> plot (x, y). xlabel (‘string’) ylabel (‘string’) title (‘string’). >> xlabel (‘x-axis’) >> ylabel (‘y-axis’) >> title (‘2D graph’). figure (n) hold on. >> t = linspace (0, 2*pi, 100); - PowerPoint PPT Presentation

Citation preview

Page 1: plot (x-values, y-values)

plot (x-values, y-values)plot (x-values, y-values)

>> x = linspace (-3, 3, 20);>> x = linspace (-3, 3, 20);

>> y = 2*x – 1;>> y = 2*x – 1;

>> plot (x, y)>> plot (x, y)

Page 2: plot (x-values, y-values)

xlabel (‘string’)xlabel (‘string’)ylabel (‘string’)ylabel (‘string’)title (‘string’)title (‘string’)

>> xlabel (‘x-axis’)>> xlabel (‘x-axis’)

>> ylabel (‘y-axis’)>> ylabel (‘y-axis’)

>> title (‘2D graph’)>> title (‘2D graph’)

Page 3: plot (x-values, y-values)

figure (n)hold on

>> t = linspace (0, 2*pi, 100);

>> y1 = sin(t);

>> figure (2)

>> plot (t, y1)

>> y2 = cos(t)

>> hold on

>> plot (t, y2)

Page 4: plot (x-values, y-values)

Plot (x-values, y-values, ‘style Plot (x-values, y-values, ‘style option’)option’)

Color Color Line Line Marker Marker

y (yellow)y (yellow) - (solid)- (solid) + (plus sign)+ (plus sign)

m (magenta)m (magenta) -- (dashed)-- (dashed) o (circle)o (circle)

c (cyan)c (cyan) : (dotted): (dotted) * (asterisk)* (asterisk)

r (red)r (red) -. (dash-dot)-. (dash-dot) x (x-marker)x (x-marker)

g (green)g (green) . (point). (point)

b (blue)b (blue) ^ (up triangle)^ (up triangle)

w (white)w (white) s (square)s (square)

k (black)k (black) d (diamond)d (diamond)

p (pentagram)p (pentagram)

h (hexagram)h (hexagram)

Page 5: plot (x-values, y-values)

>>>> t = linspace (0, 2*pi, 100);t = linspace (0, 2*pi, 100); >> y1 = sin(t); >> y1 = sin(t); >> y2 = cos(t); >> y2 = cos(t);

>> plot (t, y1, ‘y’, t, y2, ‘r:-’) >> plot (t, y1, ‘y’, t, y2, ‘r:-’) >> xlabel (‘t-axis’) >> xlabel (‘t-axis’) >> ylabel (‘y-axis’) >> ylabel (‘y-axis’)

>> title (‘trigo curves’) >> title (‘trigo curves’)

Page 6: plot (x-values, y-values)

text (x-coordinate, y-coordinate, ‘string’)text (x-coordinate, y-coordinate, ‘string’)

>> text (pi/2, 1, ‘y = sin t’)>> text (pi/2, 1, ‘y = sin t’)

gtext (‘string’)gtext (‘string’)

>> gtext (‘y = cos t’)>> gtext (‘y = cos t’)

legend (‘string 1’, ‘string 2’, . . .)legend (‘string 1’, ‘string 2’, . . .) >> legend (‘y = sin t’, ‘y = cos t’)>> legend (‘y = sin t’, ‘y = cos t’)

Page 7: plot (x-values, y-values)

axis ([xmin xmax ymin ymax])axis ([xmin xmax ymin ymax])

>> y3 = tan(t);>> y3 = tan(t);

>> hold on>> hold on

>> plot (t, y3, ‘g : d’)>> plot (t, y3, ‘g : d’)

>> axis ([0 7 -3 3]) >> axis ([0 7 -3 3])

Page 8: plot (x-values, y-values)

line (xdata, ydata, property name, property

value) >> y4 = sec(t); >> line (t, y4, ‘marker’, ‘+’)

Page 9: plot (x-values, y-values)

area

>> x = linspace (-3*pi, 3*pi, 100);

>> y = -sin(x)./x;

>> area (x, y)

Page 10: plot (x-values, y-values)

comet comet

>> q = linspace (0, 10*pi, 200);>> q = linspace (0, 10*pi, 200);

>> y = q.*sin(q);>> y = q.*sin(q);

>> comet (q, y)>> comet (q, y)

Page 11: plot (x-values, y-values)

pie

>> cont = char (‘Asia’, ‘Europe’, ‘Africa’, ‘N. America’, ‘S. America’); >> pop = [3332; 696; 694; 437; 307]; >> pie (pop) >> for I = 1 : 5, gtext (cont (i, :));

end

Page 12: plot (x-values, y-values)

Stem

>> t = linspace (0, 2*pi, 200);

>> f = exp (-0.2*t).*sin(t);

>> stem (t, f)

Page 13: plot (x-values, y-values)

Stairs Stairs >> t = linspace (0, 2*pi, 200); >> r = sqrt (abs (2*sin(5*t))); >> y = r.*sin(t); >> stairs (t, y) >> axis ([0 pi 0 inf]);

Page 14: plot (x-values, y-values)

Subplot (m, n, p)plot3 (x, y, z, ‘style-option’)xlabel (‘string’)ylabel (‘string’)zlabel (‘string’)

>> t = linspace (0, 1, 100);

>> x = t; y = t^; z = t ^ 3;

>> subplot (2, 1, 1)

>> plot3 (x, y, z, ‘r’)

Page 15: plot (x-values, y-values)

grid grid >> grid>> grid

view (a, b)view (a, b) >> subplot (2, 1, 2)>> subplot (2, 1, 2) >> view (60, 60)>> view (60, 60)

Comet3Comet3 >> t = linspace (0, 10*pi, 100);>> t = linspace (0, 10*pi, 100); >> x = cos(t);>> x = cos(t); >> y = sin(t);>> y = sin(t); >> comet3 (t, x, y)>> comet3 (t, x, y)