>> figureGraphs are drawn with the command
plot. The command
>> plot(v,w,x,y)plots the points (
To determine the appearance of your graph, after plotting a vector you can add the color and linestyle of graph. For example, the command
>> plot(x,y,'r--')will plot
help plotto see other line, marker and color options.
>> x = 0:2*pi/99:2*pi; >> y = (sin(x)+2*x)./(1+x.^2); >> figure >> plot(x,y)
When drawing a graph, the axes are chosen automatically. You can choose the lengths of the axes yourself with
>> axis([XMIN XMAX YMIN YMAX])which takes care that the graph is drawn in the rectangle XMIN
>> hold onMATLAB then holds the graphs. The command
>> hold offrestores the state in which every new plot command makes the previous plot disappear.
>> shgThe graphical screen remains the the same until either a new plot command is given or until it is erased. The command for erasing the graphical screen is
>> clfThe command
>> griddraws a grid in the graph.
>> title('title')puts the title indicated by the string between the quotes above the plot. In the example above, the title will be the word `title'.
>> text(x,y,'string')puts the text `string' at the point (x,y) of the last plot.
>> xlabel('text')writes information along the x-axis.
>> ylabel('text')does the same for the y-axis.
bar(x)produces a bar-plot of vector
plot3(x,y,z)produces a three-dimensional curve between the points, whose coordinates are given in the vectors
mesh(X,Y,Z)produces a three-dimensional surface between the grid points, whose coordinates are given in the matrices
contour(X,Y,Z)produces level curves in
You can save a figure by selecting "File
help print for additional information. When you want to be able to open and modify your figures again in MATLAB, you should save your figure as a .fig file.