Matériaux
336 pages
Français

Découvre YouScribe en t'inscrivant gratuitement

Je m'inscris

Matériaux

-

Découvre YouScribe en t'inscrivant gratuitement

Je m'inscris
Obtenez un accès à la bibliothèque pour le consulter en ligne
En savoir plus
336 pages
Français
Obtenez un accès à la bibliothèque pour le consulter en ligne
En savoir plus

Description

Matériaux

Informations

Publié par
Publié le 11 janvier 2011
Nombre de lectures 131
Langue Français
Poids de l'ouvrage 4 Mo

Extrait

How to Contact The MathWorks:
www.mathworks.com comp.softsys.matlab
suggest@mathworks.combugs@mathworks.comdoc@mathworks.com
ISBN 0975578766
Web Newsgroup
Product enhancement suggestions Bug reports Documentation error reports
Learning MATLAB COPYRIGHT 1984  2005 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, for, or through the federal government of the United States. By accepting delivery of the Program or Documentation, the government hereby agrees that this software or documentation qualifies as commercial computer software or commercial computer software documentation as such terms are used or defined in FAR 12.212, DFARS Part 227.72, and DFARS 252.2277014. Accordingly, the terms and conditions of this Agreement and only those rights specified in this Agreement, shall pertain to and govern the use, modification, reproduction, release, performance, display, and disclosure of the Program and Documentation by the federal government (or other entity acquiring for or through the federal government) and shall supersede any conflicting contractual terms or conditions. If this License fails to meet the government's needs or is inconsistent in any respect with federal procurement law, the government agrees to return the Program and Documentation, unused, to The MathWorks, Inc.
Trademarks MATLAB, Simulink, Stateflow, Handle Graphics, RealTime Workshop, and xPC TargetBox are registered trademarks of The MathWorks, Inc. Other product or brand names are trademarks or registered trademarks of their respective holders.
Patents The MathWorks products are protected by one or more U.S. patents. Please see www.mathworks.com/patentsfor more information.
Revision History August 1999 First printing January 2001 Second printing November 2002 Third printing July 2004 Fourth printing December 2005 Fifth printing
New manual Revised for MATLAB 6.0 (Release 12) Revised for MATLAB 6.5 (Release 13) Revised for MATLAB 7.0 (Release 14) Revised for MATLAB 7.1 (Release 14SP3)
Introducing MATLAB & Simulink Student Version 1
Quick Start. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12
About the Student Version. . . . . . . . . . . . . . . . . . . . . . . . . . . . .13 Student Use Policy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13 Student Version Activation . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14
Obtaining Additional MathWorks Products . . . . . . . . . . . . .15
Getting Started with MATLAB . . . . . . . . . . . . . . . . . . . . . . . . .16
Finding Reference Information . . . . . . . . . . . . . . . . . . . . . . . .17
Troubleshooting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18
Other Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19 Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19 MathWorks Web Site . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19 MathWorks Academia Web Site . . . . . . . . . . . . . . . . . . . . . . . . .19 MATLAB and Simulink Based Books . . . . . . . . . . . . . . . . . . . .19 MathWorks Store . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19 MATLAB Central — File Exchange/Newsgroup Access . . . . .110 Technical Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .110
Differences Between the Student and Professional Versions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .111 MATLAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .111 Simulink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .111 Symbolic Math Toolbox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .112
Contents
i
ii
Contents
2
3
Installing MATLAB & Simulink Student Version
Installing on Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22 System Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22 Installing and Activating the Student Version . . . . . . . . . . . . .23 Installing Additional Toolboxes . . . . . . . . . . . . . . . . . . . . . . . . . .25 Accessing the Online Documentation (Help) . . . . . . . . . . . . . . .26
Installing on Mac OS X. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 System Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .27 Installing and Activating the Student Version . . . . . . . . . . . . .28 Installing Additional Toolboxes . . . . . . . . . . . . . . . . . . . . . . . . .214 Accessing the Online Documentation (Help) . . . . . . . . . . . . . .214 Mac OS X Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . .215
Installing on Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .216 System Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .216 Installing and Activating the Student Version . . . . . . . . . . . .217 Installing Additional Toolboxes . . . . . . . . . . . . . . . . . . . . . . . . .222 Accessing the Online Documentation (Help) . . . . . . . . . . . . . .222
Introduction
About MATLAB and Simulink . . . . . . . . . . . . . . . . . . . . . . . . . .32 What Is MATLAB? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .32 What Is Simulink? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .34
MATLAB Documentation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 MATLAB Online Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .35
Starting and Quitting MATLAB . . . . . . . . . . . . . . . . . . . . . . . .37 Starting MATLAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .37 Quitting MATLAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .37 MATLAB Desktop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .37
4
Matrices and Arrays
Matrices and Magic Squares. . . . . . . . . . . . . . . . . . . . . . . . . . . 42 Entering Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .43 sum, transpose, and diag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .44 Subscripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .46 The Colon Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .47 The magic Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .48
Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .410 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .410 Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .411 Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .411 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .412 Examples of Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .413
Working with Matrices. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414 Generating Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .414 The load Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .415 MFiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .415 Concatenation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .416 Deleting Rows and Columns . . . . . . . . . . . . . . . . . . . . . . . . . . .417
More About Matrices and Arrays . . . . . . . . . . . . . . . . . . . . . .418 Linear Algebra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .418 Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .421 Multivariate Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .424 Scalar Expansion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .425 Logical Subscripting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .426 The find Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .427
Controlling Command Window Input and Output . . . . . . .428 The format Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .428 Suppressing Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .430 Entering Long Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . .430 Command Line Editing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .430
iii
iv
Contents
5
Graphics
Overview of MATLAB Plotting . . . . . . . . . . . . . . . . . . . . . . . . .52 The Plotting Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .52 Graph Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .55 Figure Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .57 Arranging Graphs Within a Figure . . . . . . . . . . . . . . . . . . . . .513 Selecting Plot Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .514
Editing Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .516 Plot Editing Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .516 Using Functions to Edit Graphs . . . . . . . . . . . . . . . . . . . . . . . .519
Examples — Using MATLAB Plotting Tools. . . . . . . . . . . . . 520 Modifying the Graph Data Source . . . . . . . . . . . . . . . . . . . . . .527
Preparing Graphs for Presentation . . . . . . . . . . . . . . . . . . . .529 Modify the Graph to Enhance the Presentation . . . . . . . . . . .530 Printing the Graph . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .533 Exporting the Graph . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .535
Basic Plotting Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .538 Creating a Plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .538 Multiple Data Sets in One Graph . . . . . . . . . . . . . . . . . . . . . . .540 Specifying Line Styles and Colors . . . . . . . . . . . . . . . . . . . . . . .541 Plotting Lines and Markers . . . . . . . . . . . . . . . . . . . . . . . . . . . .541 Imaginary and Complex Data . . . . . . . . . . . . . . . . . . . . . . . . . .543 Adding Plots to an Existing Graph . . . . . . . . . . . . . . . . . . . . . .544 Figure Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .546 Multiple Plots in One Figure . . . . . . . . . . . . . . . . . . . . . . . . . . .546 Controlling the Axes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .548 Axis Labels and Titles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .549 Saving Figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .551
Mesh and Surface Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .552 Visualizing Functions of Two Variables . . . . . . . . . . . . . . . . . .552
Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .558 Reading and Writing Images . . . . . . . . . . . . . . . . . . . . . . . . . . .559
6
Printing Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .560
Handle Graphics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .562 Using the Handle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .562 Graphics Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .563 Setting Object Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .565 Specifying the Axes or Figure . . . . . . . . . . . . . . . . . . . . . . . . . .568 Finding the Handles of Existing Objects . . . . . . . . . . . . . . . . .569
Animations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 571 Erase Mode Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .571 Creating Movies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .573
Programming
Flow Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 if . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .62 switch and case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .64 for . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .65 while . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .66 continue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .66 break . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .67 try  catch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .68 return . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .68
Other Data Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .69 Multidimensional Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .69 Cell Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .611 Characters and Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .613 Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .616
Scripts and Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .619 Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .620 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .621 Types of Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .623 Global Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .625
v
vi
Contents
7
8
Passing String Arguments to Functions . . . . . . . . . . . . . . . . . .626 The eval Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .627 Function Handles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .628 Function Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .628 Vectorization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .631 Preallocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .631
Creating Graphical User Interfaces
What Is GUIDE?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .72
Laying Out a GUI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .73 Starting GUIDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .73 The Layout Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .74
Programming a GUI. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
Desktop Tools and Development Environment
Desktop Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .82 Arranging the Desktop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .83 Start Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .83
Command Window and Command History. . . . . . . . . . . . . . .84 Command Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .84 Command History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .85
Help Browser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .86
Current Directory Browser and Search Path. . . . . . . . . . . . 89 Current Directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .89 Search Path . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .810
  • Univers Univers
  • Ebooks Ebooks
  • Livres audio Livres audio
  • Presse Presse
  • Podcasts Podcasts
  • BD BD
  • Documents Documents