View
235
Download
0
Category
Preview:
Citation preview
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)
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’)
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)
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)
>>>> 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’)
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’)
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])
line (xdata, ydata, property name, property
value) >> y4 = sec(t); >> line (t, y4, ‘marker’, ‘+’)
area
>> x = linspace (-3*pi, 3*pi, 100);
>> y = -sin(x)./x;
>> area (x, y)
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)
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
Stem
>> t = linspace (0, 2*pi, 200);
>> f = exp (-0.2*t).*sin(t);
>> stem (t, f)
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]);
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’)
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)
Recommended