11. Plotting points

# 11. Plotting points - Plotting Points A simple plot Graph...

This preview shows pages 1–6. Sign up to view the full content.

©2009 by L. Lagerstrom Plotting Points • A simple plot • Graph options: axes, box, grid, title, etc. • Compass plots • Polar plots • Plotting complex numbers • Complex number rotation plot

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Matlab code Figure window display ©2009 by L. Lagerstrom A Simple Plot %Matlab allows us to create graphs %that are displayed in the so-called %Figure Window. Just as we have used %a representative Command Window %side-by-side with a listing of %Matlab code, we'll do the same with %the Figure Window (at the right). %To plot an (x,y) point as a red %circle, we use the plot function: x = 5; y = 3; figure(1) clf plot(x,y,'ro') %'ro' = red circle %The "figure(1)" opens the Figure %Window and brings it to the front %of all other open windows on the %screen. The "clf" clears the Figure %Window (in case there was a previous %plot in it). %Note that Matlab automatically sets %the axis scaling, etc. 4 4.5 5 5.5 6 2 2.5 3 3.5 4
©2009 by L. Lagerstrom Graph Options Obviously our simple plot leaves a lot to be desired. Before actually doing the graph, it's useful to specify various options associated with it, such as the range for each axis, whether a grid should be shown, etc. If we don't specify anything, then Matlab will use certain default values for the display of the graph. Here are some of the customization options: • axis([xmin xmax ymin ymax]) sets the range for the x and y axes • axis square specifies a square graph (vs. rectangular) • box on (or box off) specifies a box around the outside of the graph • grid on (or grid off) specifies the display of a grid (or not) The next slide shows these in action.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Matlab code Figure window display ©2009 by L. Lagerstrom Customizing the Simple Plot %Here's a more customized plot: x = 5; y = 3; figure(1) clf plot(x,y,'ro') axis([0 6 0 6]) axis square box on grid on %Note that the axis, box, and grid %commands should come after the plot %command. 0 1 2 3 4 5 6 0 1 2 3 4 5 6
Matlab code Figure window display ©2009 by L. Lagerstrom Adding a Title and Axis Labels %We can add a title at the top of the %plot and labels for each axis using %the title, xlabel, and ylabel %functions, as shown. Each of these %takes a string as an input parameter. %(Note that we also turned the box %and grid off to see how that %looks.) x = 5; y = 3; figure(1) clf plot(x,y,'ro') axis([0 6 0 6]) axis square box off grid off title('A Simple Plot') xlabel('The x axis') ylabel('The y axis') 0 1 2 3 4 5 6 0 1 2 3 4 5 6 A Simple Plot The x axis The y axis

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 02/23/2010 for the course ENG 42325 taught by Professor Lagerstrom during the Spring '10 term at UC Davis.

### Page1 / 17

11. Plotting points - Plotting Points A simple plot Graph...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online