05-07-2013, 03:12 PM
2-D AND 3-D GRAPHICS
3-D GRAPHICS.ppt (Size: 318.5 KB / Downloads: 19)
Introduction into 2-D graphs
Matlab provides you easy means to plot even the most complicated of graphs.
When you plot a graph it appears in a separate window( not the command window) and is called a figure.
A graph has many properties and they can be changed to give a better look to the plot.
E.g.- an axis has properties like color, scale and limits of the axis, etc.
The plotted line has properties like line style, and type of marker used at each data point.
You can save the figure as a .fig file. All the properties of the figure are also saved.
Figure Tools
There are two toolbars in the view menu.
Figure toolbar
Camera toolbar
Try experimenting with all the tools in the tools menu.
Plotting variables from the workspace
Right click on the variable you want to plot. Choose one among the many graph options available.
The values of the chosen variable are plotted along the y-axis and the corresponding indices are plotted against the x-axis.
Plot Editing Mode
Select the edit plot( arrow button) option in the figure toolbar.
Now, you can select objects by clicking on them in the graph.
In the plot edit mode, double clicking on an object in the graph starts the property editor. This is another way we can change object properties.
Some more plotting functions
plot(y) plots a graph of the elements of y versus the indices of the elements of y.
plotyy(x1,y1,x2,y2,’function1’,’function2’) plots x1 versus y1 with y-axis labelling on the left and plots x2 versus y2 with y-axis labelling on the right. Function1 can be a string specifying plot, semilogx, semilogy, loglog, stem.
Figure
To open a new figure window type figure. When there are multiple fig windows, the plot is displayed on the current fig window. The current window is the one which is most recently used or clicked in.
To make an existing figure window the current figure, you can type figure(n), where n is the number in the figure title bar.
To clear a figure’s properties use: clf reset The reset option will restore the properties to their defaults.
Surf
A surface plot is similar to a mesh plot except that MATLAB colors the rectangular faces of the surface. The color of each faces is determined by the values of Z and the colormap (a colormap is an ordered list of colors).
You can plot the sinc function as shown in the previous example. Replace mesh by surf.