angles = [o:pi/3:2*pi]
y = sin(angles)
plot(angles, y)
Plot smoother curves (vector)
angles = linspace(0, 2*pi, 100) % 100 points equally spaced btw 0 and 2pi
y = sin(angles)
plot(angles, y)
Basic options
'.' = Set dots plot style
'@' = Set points plot style
'-@' = Set linespoints plot style
'^' = Set impulses plot style
'L' = Set steps plot style
'N' = Interpreted as the plot color if N is an integer in the range 1 to 6
'NM' = if N an integer in the range 1 to 6 -> color
if M an integer in the range 1 to 6 -> point style
This is only valid in combination with the '@' or '-@' specifier
'C' = plot color
'";title;"' = here '"title"' is the label for the key
1 = red / *
2 = greed / +
3 = blue / o
4 = magenta / x
5 = cyan / house
6 = brown / there exists
Example:
plot(x, y, "@12", x, y2, x, y3, "4", x, y4, "+"), This command plot
'y' with color 1 (red) and points of type 2 (+),
'y2' with lines
'y3' with lines of color 4 (magenta)
'y4' with points displayed as '+'
plot(b, '*'), plot the data in the var. b w. points displayed as '*'.
t = 0:0.1:6.3;
plot(t, cos(t), "-;cos(t);", t, sin(t), "+3; sin(t);")
Title and Labels
title('Graph of y = sin(x)')
xlabel('Angle')
ylabel('Value')
Colors and Styles for symbols and lines in the plot command (see help plot)
(M = only available in Matlab)
w = white
m = magneta
c = cyan
r = red
g = green
b = blue
y = yellow
k = black
. = point
o = circle
x = x-mark
+ = plus
* = star
s = square (M)
d = diamond (M)
v = triangle (down) (M)
^ = triangle (up) (M)
< = triangle (left) (M)
> = triangle (right) (M)
p = pentagram (M)
h = hexagram (M)
- = solid
: = dotted (M)
-. = dashdot (M)
-- = dashed (M)
Extra
grid on % turn on grid
grid off
hold on % keep current plot to add more
hold off
figure (N) % plot graph in window N. If no number is specified, the next number is called. If command not called, graph will be plotted in exactly the same window.
More info:
1) plot is the user-defined function from the file /usr/share/octave/2.9.9/m/plot/plot.m
2) Additional help for built-in functions and operators is
available in the on-line version of the manual. Use the command
`doc
3) See also: semilogx, semilogy, loglog, polar, mesh, contour,
__pltopt__ bar, stairs, errorbar, replot, xlabel, ylabel, title,
print.
No comments:
Post a Comment