Plotting with MATLAB


We have been exposed to different MATLAB commands that generate and customize plots of data. To a great extent this has been accomplished in a trial-and-error fashion (or a use and abuse fashion) and it is appropriate now to make some further statements about these plotting capabilities.


xy plots


The basic plot command in MATLAB generates as an output, an xy plot of data provided as inputs or arguments to the plot function. The data here is typically organized in arrays and depending on the nature and size of this array data, the plot command interprets the data in various ways.



Data markers and line types


When multiple curves are plotted on a figure in MATLAB, different colors are automatically selected. If different colors, line styles or data markers are preferred these can be specified as input arguments to the plot command. Table 4.2-1 details the different colors, line styles and data markers that are available. These can also be modified in the figure window in MATLAB.


Labeling curves and data


Several commands are provided to allow you to customize and label plots in MATLAB. We have used most of these in class but you should feel free to experiment with the use of the following:



Other xy plots


MATLAB provides a variety of other plot formats for you to use. Most of these are commonly used in different situations.



3-D plots


MATLAB has several plot commands that generate three-dimensional plots of data. There are basically four different types of plots that can be constructed with some variations.





>> [d,th]=meshgrid([1:.1:10],[.4:.01:1.4]);

>> L=(100./d)-(d./tan(th))+2*(d./sin(th));

>> mesh(d,th,L)


The plot can now be customized with the usual labels, grids, etc..