Friday, February 24, 2012

MATLAB Graph: Introduction

All of these stuffs are abstracted from Matlab Help file, re-writing/summarizing them down will enhance my understanding over this part:

Three Components of a Graph:

  • Figure window: display the graph
  • Coordinate system: so that graph is placed within axis, which are contained by the Figure
  • other graph objects: lines and surfaces
Basic Plotting Commands:
  • plot: graph 2-D data with linear scales for both axes
  • plot3: graphe 3-D data with linear scales for both axes
  • loglog, semilogx, lemilogy, plotyy et al. 
Plotting Steps:
  1. Preparing the data                                      [x = 0:0.1:1; y = bessel(1,x);]
  2. Select a window and position a plot region within the window  [figure 1; subplot(2,2,1);]
  3. Call elementary plotting function               [h = plot(x,y)]
  4. Select line and marker characters               [set(h, 'LineWidth', 2, {'LineStyle'}, {'--'} ]
  5. Set axis limit, tick marks, and grid lines     [axis ([0 12 -0.5 1]); grid on;]
  6. Annotate the graph with axis labels, legend and text  [xlabel('Time'); legand(h, 'First')]
  7. export graph                                              [ print -depsc -tiff -r200 myplot]
The Figure Window:
  • MATLAB directs graphics output to a window separated from command window, which is refereed to as Figure
  • Graphics functions automatically create new figure windows if none currently exist. If a figure already exists, MATLAB uses that window.
These are some of the most common matlab graphic process, and there are other specialized figures, such as contour, histogram, et al, which I will not detailed them here.

No comments:

Post a Comment