11p. Plotting points _printable_

11p. Plotting points _printable_ - A Simple Plot Plotting...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
1 ©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 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. 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
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 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 Matlab code
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 5

11p. Plotting points _printable_ - A Simple Plot Plotting...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online