Using Matlab Graphics - V 6 (2002) WW.pdf

(13244 KB) Pobierz
Using MATLAB Graphics
M AT LA B §
The Language of Technical Computing
Compu tation
Visuali zation
Program ming
Using MATLAB Graphics
Version 6
326710982.009.png 326710982.010.png
How to Contact The MathWorks:
www.mathworks.com
Web
comp.soft-sys.matlab
Newsgroup
support@mathworks.com
Technical support
suggest@mathworks.com
Product enhancement suggestions
bugs@mathworks.com
Bug reports
doc@mathworks.com
Documentation error reports
service@mathworks.com
Order status, license renewals, passcodes
info@mathworks.com
Sales, pricing, and general information
508-647-7000
Phone
508-647-7001
Fax
The MathWorks, Inc.
Mail
3 Apple Hill Drive
Natick, MA 01760-2098
For contact information about worldwide offices, see the MathWorks Web site.
Using MATLAB Graphics
COPYRIGHT 1984 - 2002 by The MathWorks, Inc.
The software described in this document is furnished under a license agreement. The software may be used
or copied only under the terms of the license agreement. No part of this manual may be photocopied or repro-
duced in any form without prior written consent from The MathWorks, Inc .
FEDERAL ACQUISITION: This provision applies to all acquisitions of the Program and Documentation by
or for the federal government of the United States. By accepting delivery of the Program, the government
hereby agrees that this software qualifies as "commercial" computer software within the meaning of FAR
Part 12.212, DFARS Part 227.7202-1, DFARS Part 227.7202-3, DFARS Part 252.227-7013, and DFARS Part
252.227-7014. The terms and conditions of The MathWorks, Inc. Software License Agreement shall pertain
to the government’s use and disclosure of the Program and Documentation, and shall supersede any
conflicting contractual terms or conditions. If this license fails to meet the government’s minimum needs or
is inconsistent in any respect with federal procurement law, the government agrees to return the Program
and Documentation, unused, to MathWorks.
MATLAB, Simulink, Stateflow, Handle Graphics, and Real-Time Workshop are registered trademarks, and
TargetBox is a trademark of The MathWorks, Inc.
Other product or brand names are trademarks or registered trademarks of their respective holders.
Printing History: January 1997 First printing New for MATLAB 5.1
January 1998 Second printing Revised for MATLAB 5.2
January 1999 Third printing Revised for MATLAB 5.3 (Release 11)
September 2000 Fourth printing Revised for MATLAB 6.0 (Release 12)
June 2001
Online only
Revised for MATLAB 6.1 (Release 12.1)
July 2002
Online only
Revised for MATLAB 6.5 (Release 13)
326710982.011.png 326710982.012.png 326710982.001.png 326710982.002.png 326710982.003.png 326710982.004.png
Contents
Graphics
1
Overview of MATLAB Graphics
Plotting Your Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
Anatomy of a Plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3
Editing Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4
Interactive Plot Editing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4
Using Functions to Edit Graphs . . . . . . . . . . . . . . . . . . . . . . . . . 1-4
Using Plot Edit Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-5
Starting Plot Edit Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-6
Exiting Plot Edit Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-6
Selecting Objects in a Graph . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-6
Cutting, Copying, and Pasting Objects . . . . . . . . . . . . . . . . . . . 1-7
Moving and Resizing Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-7
Editing Objects in a Graph . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-8
Saving Your Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-9
Saving a Graph in MAT-File Format . . . . . . . . . . . . . . . . . . . . . 1-9
Saving to a Different Format (Exporting Figures) . . . . . . . . . 1-10
Printing Figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-10
Getting Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-12
Changing Your View of an Axes . . . . . . . . . . . . . . . . . . . . . . . 1-13
Zooming In and Out on an Axes . . . . . . . . . . . . . . . . . . . . . . . . 1-13
Rotating 3-D Axes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-14
Using the Property Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-15
Starting the Property Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-16
i
326710982.005.png 326710982.006.png
Closing the Property Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-17
Editing Object Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-17
Navigating Among Objects in a Graph . . . . . . . . . . . . . . . . . . . 1-18
Identifying Objects in a Graph . . . . . . . . . . . . . . . . . . . . . . . . . 1-20
Applying Your Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-21
Using the Data Statistics Tool . . . . . . . . . . . . . . . . . . . . . . . . 1-22
Adding Plots of Statistics to a Graph . . . . . . . . . . . . . . . . . . . . 1-22
Saving Statistics to the Workspace . . . . . . . . . . . . . . . . . . . . . . 1-23
2
Basic Plotting
Basic Plotting Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
Creating Line Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
Specifying Line Style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4
Specifying the Color and Size of Lines . . . . . . . . . . . . . . . . . . . . 2-6
Adding Plots to an Existing Graph . . . . . . . . . . . . . . . . . . . . . . . 2-7
Plotting Only the Data Points . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8
Plotting Markers and Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-9
Line Styles for Black and White Output . . . . . . . . . . . . . . . . . 2-10
Setting Default Line Styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-11
Line Plots of Matrix Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-13
Plotting Imaginary and Complex Data . . . . . . . . . . . . . . . . . 2-15
Plotting with Two Y-Axes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-16
Combining Linear and Logarithmic Axes . . . . . . . . . . . . . . . . . 2-16
Setting Axis Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-19
Axis Limits and Ticks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-19
Example – Specifying Ticks and Tick Labels . . . . . . . . . . . . . . 2-22
Setting Aspect Ratio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-23
Figure Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-26
Displaying Multiple Plots per Figure . . . . . . . . . . . . . . . . . . . . 2-26
ii
Contents
326710982.007.png
Specifying the Target Axes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-28
Default Color Scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-28
3
Formatting Graphs
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2
Adding Titles to Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3
Using the Title Option on the Insert Menu . . . . . . . . . . . . . . . . 3-3
Using the Property Editor to Add a Title . . . . . . . . . . . . . . . . . . 3-4
Using the title Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-5
Adding Legends to Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-6
Using the Legend Option on the Insert Menu . . . . . . . . . . . . . . 3-7
Using the Legend Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-7
Positioning the Legend . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-8
Editing the Legend . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-9
Removing the Legend . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-10
Adding Axis Labels to Graphs . . . . . . . . . . . . . . . . . . . . . . . . . 3-11
Using the Label Options on the Insert Menu . . . . . . . . . . . . . . 3-12
Using the Property Editor to Add Axis labels . . . . . . . . . . . . . 3-12
Using Axis-Label Commands . . . . . . . . . . . . . . . . . . . . . . . . . . 3-15
Adding Text Annotations to Graphs . . . . . . . . . . . . . . . . . . . . 3-17
Creating Text Annotations in Plot Editing Mode . . . . . . . . . . 3-18
Creating Text Annotations with the text or gtext Command . 3-18
Text Alignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-22
Example – Aligning Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-23
Editing Text Annotations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-24
Mathematical Symbols, Greek Letters, and TeX Characters . 3-25
Using Character and Numeric Variables in Text . . . . . . . . . . 3-27
Example - Multiline Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-28
Drawing Text in a Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-29
Adding Arrows and Lines to Graphs . . . . . . . . . . . . . . . . . . . 3-31
iii
326710982.008.png
Zgłoś jeśli naruszono regulamin