|Department of Engineering|
|University of Cambridge > Engineering Department > computing help|
Obtaining graphical output is very easy. The basic syntax is plot(x,y) which plots vector y (ordinate) against vector x (abscissa). For example to plot against t, using the vectors we have already created, type
plot(t,sint)The plot appears in a separate graphics window. Now you can add some axis labels and a rectangular grid by using menus or by typing
xlabel('t'), ylabel('sin t'), gridTo get your graph in red rather than black, and with a title, type:
plot(t,sint,'r'), title('Half period sine wave')To position text onto the graph using cross-hairs the gtext command is available. Type help gtext for more information.
There are many other possibilities for controlling graphical output. You can have log-log or semi-log graphs, 3-D graphs of surfaces, contour plots, you can overlay various graphs on top of each other, control the axis ranges, and so on.
You can obtain hard copy of a graph (in fact, of the current contents of the Graphics Window) by typing print (or cuedpr if you want to save paper).
|| computing help ||