1. Trang chủ
  2. » Kỹ Thuật - Công Nghệ

MATLAB programming fundamentals

1,1K 450 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 1.078
Dung lượng 5,78 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

9-17 Modify Units, Descriptions and Table Variable Names 9-24 Access Data in a Table.. 9-40 Split Table Data Variables and Apply Functions.. 9-49 Access Data Using Numeric or Named Index

Trang 1

Programming Fundamentals

Trang 2

User community: www.mathworks.com/matlabcentral

Technical support: www.mathworks.com/support/contact_us

The MathWorks, Inc

3 Apple Hill Drive

Natick, MA 01760-2098

MATLAB Programming Fundamentals

© COPYRIGHT 1984–2015 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 reproduced 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 and Simulink are registered trademarks of The MathWorks, Inc See

www.mathworks.com/trademarks for a list of additional trademarks Other product or brand names may be trademarks or registered trademarks of their respective holders.

Patents

MathWorks products are protected by one or more U.S patents Please see

Trang 3

September 2005 Online only Revised for MATLAB 7.1 (Release 14SP3) March 2006 Online only Revised for MATLAB 7.2 (Release 2006a) September 2006 Online only Revised for MATLAB 7.3 (Release 2006b) March 2007 Online only Revised for MATLAB 7.4 (Release 2007a) September 2007 Online only Revised for Version 7.5 (Release 2007b) March 2008 Online only Revised for Version 7.6 (Release 2008a) October 2008 Online only Revised for Version 7.7 (Release 2008b) March 2009 Online only Revised for Version 7.8 (Release 2009a) September 2009 Online only Revised for Version 7.9 (Release 2009b) March 2010 Online only Revised for Version 7.10 (Release 2010a) September 2010 Online only Revised for Version 7.11 (Release 2010b) April 2011 Online only Revised for Version 7.12 (Release 2011a) September 2011 Online only Revised for Version 7.13 (Release 2011b) March 2012 Online only Revised for Version 7.14 (Release 2012a) September 2012 Online only Revised for Version 8.0 (Release 2012b) March 2013 Online only Revised for Version 8.1 (Release 2013a) September 2013 Online only Revised for Version 8.2 (Release 2013b) March 2014 Online only Revised for Version 8.3 (Release 2014a) October 2014 Online only Revised for Version 8.4 (Release 2014b) March 2015 Online only Revised for Version 8.5 (Release 2015a) September 2015 Online only Revised for Version 8.6 (Release 2015b)

Trang 5

Syntax Basics

1

Create Variables 1-2 Create Numeric Arrays 1-3 Continue Long Statements on Multiple Lines 1-5 Call Functions 1-6 Ignore Function Outputs 1-7 Variable Names 1-8

Valid Names 1-8

Conflicts with Function Names 1-8 Case and Space Sensitivity 1-10 Command vs Function Syntax 1-12

Command and Function Syntaxes 1-12

Avoid Common Syntax Mistakes 1-13

How MATLAB Recognizes Command Syntax 1-14 Common Errors When Calling Functions 1-16

Conflicting Function and Variable Names 1-16

Undefined Functions or Variables 1-16

Trang 6

Introduction 2-2

Array Operations 2-2

Matrix Operations 2-4 Relational Operators 2-7

Relational Operators and Arrays 2-7

Relational Operators and Empty Arrays 2-7 Operator Precedence 2-9

Precedence of AND and OR Operators 2-9

Overriding Default Precedence 2-9 Average Similar Data Points Using a Tolerance 2-11 Group Scattered Data Using a Tolerance 2-14 Special Values 2-17 Conditional Statements 2-19 Loop Control Statements 2-21 Regular Expressions 2-23

What Is a Regular Expression? 2-23

Steps for Building Expressions 2-25

Operators and Characters 2-28 Lookahead Assertions in Regular Expressions 2-39

Lookahead Assertions 2-39

Overlapping Matches 2-39

Logical AND Conditions 2-40

Trang 7

What Is a Comma-Separated List? 2-56

Generating a Comma-Separated List 2-56

Assigning Output from a Comma-Separated List 2-58

Assigning to a Comma-Separated List 2-59

How to Use the Comma-Separated Lists 2-61

Fast Fourier Transform Example 2-63 Alternatives to the eval Function 2-65

Why Avoid the eval Function? 2-65

Variables with Sequential Names 2-65

Files with Sequential Names 2-66

Function Names in Variables 2-67

Field Names in Variables 2-67

Error Handling 2-68 Symbol Reference 2-69

Trang 8

Classes (Data Types)

Overview of MATLAB Classes

Creating Integer Data 4-3

Arithmetic Operations on Integer Classes 4-4

Largest and Smallest Values for Integer Classes 4-5

Integer Functions 4-5 Floating-Point Numbers 4-6

Double-Precision Floating Point 4-6

Single-Precision Floating Point 4-6

Creating Floating-Point Data 4-7

Arithmetic Operations on Floating-Point Numbers 4-8

Largest and Smallest Values for Floating-Point Classes 4-9

Accuracy of Floating-Point Data 4-11

Avoiding Common Problems with Floating-Point

Trang 9

Identifying Numeric Classes 4-21 Display Format for Numeric Values 4-22

Default Display 4-22

Display Format Examples 4-22

Setting Numeric Format in a Program 4-23 Function Summary 4-25

The Logical Class

5

Find Array Elements That Meet a Condition 5-2

Apply a Single Condition 5-2

Apply Multiple Conditions 5-4

Replace Values that Meet a Condition 5-5 Determine if Arrays Are Logical 5-7

Identify Logical Matrix 5-7

Test an Entire Array 5-7

Test Each Array Element 5-8

Summary Table 5-9 Reduce Logical Arrays to Single Value 5-10 Truth Table for Logical Operations 5-13

Characters and Strings

6

Creating Character Arrays 6-2

Trang 10

Cell Arrays of Strings 6-7

Converting to a Cell Array of Strings 6-7

Functions for Cell Arrays of Strings 6-8 Formatting Strings 6-10

Functions that Use Format Strings 6-10

The Format String 6-11

Input Value Arguments 6-12

The Formatting Operator 6-13

Constructing the Formatting Operator 6-14

Setting Field Width and Precision 6-19

Restrictions for Using Identifiers 6-21 String Comparisons 6-23

Comparing Strings for Equality 6-23

Comparing for Equality Using Operators 6-24

Categorizing Characters Within a String 6-24 Searching and Replacing 6-26 Converting from Numeric to String 6-28

Function Summary 6-28

Converting to a Character Equivalent 6-29

Converting to a String of Numbers 6-29

Converting to a Specific Radix 6-29 Converting from String to Numeric 6-30

Function Summary 6-30

Converting from a Character Equivalent 6-30

Converting from a Numeric String 6-31

Converting from a Specific Radix 6-31

Trang 11

Represent Dates and Times in MATLAB 7-2 Specify Time Zones 7-6 Set Date and Time Display Format 7-8

Formats for Individual Date and Duration Arrays 7-8

datetime Display Format 7-8

duration Display Format 7-9

calendarDuration Display Format 7-10

Default datetime Format 7-11 Generate Sequence of Dates and Time 7-13

Sequence of Datetime or Duration Values Between

Endpoints with Step Size 7-13

Add Duration or Calendar Duration to Create Sequence ofDates 7-16

Specify Length and Endpoints of Date or Duration

Sequence 7-17

Sequence of Datetime Values Using Calendar Rules 7-18 Share Code and Data Across Locales 7-22

Write Locale-Independent Date and Time Code 7-22

Write Dates in Other Languages 7-23

Read Dates in Other Languages 7-24 Extract or Assign Date and Time Components of

Datetime Array 7-25 Combine Date and Time from Separate Variables 7-30 Date and Time Arithmetic 7-32 Compare Dates and Time 7-40 Plot Dates and Durations 7-44 Core Functions Supporting Date and Time Arrays 7-55

Trang 12

Convert Serial Date Numbers to Datetime 7-59

Convert Datetime Arrays to Numeric Values 7-59 Carryover in Date Vectors and Strings 7-61 Converting Date Vector Returns Unexpected Output 7-62

Select Data By Category 8-29

Common Ways to Access Data Using CategoricalArrays 8-29

Trang 13

Core Functions Supporting Categorical Arrays 8-49

Tables

9

Create a Table 9-2 Add and Delete Table Rows 9-9 Add and Delete Table Variables 9-13 Clean Messy and Missing Data in Tables 9-17 Modify Units, Descriptions and Table Variable Names 9-24 Access Data in a Table 9-28

Ways to Index into a Table 9-28

Create Table from Subset of Larger Table 9-29

Create Array from the Contents of Table 9-32 Calculations on Tables 9-36 Split Data into Groups and Calculate Statistics 9-40 Split Table Data Variables and Apply Functions 9-44 Advantages of Using Tables 9-49

Conveniently Store Mixed-Type Data in Single

Container 9-49

Access Data Using Numeric or Named Indexing 9-52

Use Table Properties to Store Metadata 9-53 Grouping Variables To Split Data 9-56

Grouping Variables 9-56

Trang 14

10

Create a Structure Array 10-2 Access Data in a Structure Array 10-6 Concatenate Structures 10-10 Generate Field Names from Variables 10-12 Access Data in Nested Structures 10-13 Access Elements of a Nonscalar Struct Array 10-15 Ways to Organize Data in Structure Arrays 10-17

Plane Organization 10-17

Element-by-Element Organization 10-19 Memory Requirements for a Structure Array 10-21

Cell Arrays

11

What Is a Cell Array? 11-2 Create a Cell Array 11-3

Trang 15

Preallocate Memory for a Cell Array 11-16 Cell vs Struct Arrays 11-17 Multilevel Indexing to Access Parts of Cells 11-19

Function Handles

12

Create Function Handle 12-2

What Is a Function Handle? 12-2

Creating Function Handles 12-2

Anonymous Functions 12-4

Arrays of Function Handles 12-4

Saving and Loading Function Handles 12-5 Pass Function to Another Function 12-6 Call Local Functions Using Function Handles 12-8 Compare Function Handles 12-10

Compare Handles Constructed from Named Function 12-10

Compare Handles to Anonymous Functions 12-10

Compare Handles to Nested Functions 12-11

Call Local Functions Using Function Handles 12-12

Map Containers

13

Overview of the Map Data Structure 13-2 Description of the Map Class 13-4

Trang 16

Combining Map Objects 13-8 Examining the Contents of the Map 13-9 Reading and Writing Using a Key Index 13-10

Reading From the Map 13-10

Adding Key/Value Pairs 13-11

Building a Map with Concatenation 13-12 Modifying Keys and Values in the Map 13-15

Removing Keys and Values from the Map 13-15

Modifying Values 13-16

Modifying Keys 13-16

Modifying a Copy of the Map 13-17 Mapping to Different Value Types 13-18

Mapping to a Structure Array 13-18

Mapping to a Cell Array 13-19

Combining Unlike Classes

14

Valid Combinations of Unlike Classes 14-2 Combining Unlike Integer Types 14-3

Overview 14-3

Example of Combining Unlike Integer Sizes 14-3

Example of Combining Signed with Unsigned 14-4

Trang 17

Combining Logical and Double Types 14-10

Using Objects

15

MATLAB Objects 15-2

Getting Oriented 15-2

What Are Objects and Why Use Them? 15-2

Working with Objects 15-3

Objects In the MATLAB Language 15-3

Other Kinds of Objects Used by MATLAB 15-3 General Purpose Vs Specialized Arrays 15-5

How They Differ 15-5

Using General-Purpose Data Structures 15-5

Using Specialized Objects 15-6 Key Object Concepts 15-8

Basic Concepts 15-8

Classes Describe How to Create Objects 15-8

Properties Contain Data 15-9

Methods Implement Operations 15-9

Events are Notices Broadcast to Listening Objects 15-10 Creating Objects 15-11

Class Constructor 15-11

When to Use Package Names 15-11 Accessing Object Data 15-13

Listing Public Properties 15-13

Getting Property Values 15-13

Setting Property Values 15-14 Calling Object Methods 15-15

What Operations Can You Perform 15-15

Trang 18

Getting Information About Objects 15-20

The Class of Workspace Variables 15-20

Information About Class Members 15-22

Logical Tests for Objects 15-22

Displaying Objects 15-23

Getting Help for MATLAB Objects 15-24 Copying Objects 15-25

Two Copy Behaviors 15-25

Value Object Copy Behavior 15-25

Handle Object Copy Behavior 15-26

Testing for Handle or Value Class 15-29 Destroying Objects 15-31

Object Lifecycle 15-31

Difference Between clear and delete 15-31

Defining Your Own Classes

16

Scripts and Functions

Scripts

Trang 19

Example of Evaluating Code Sections 17-8

Change the Appearance of Code Sections 17-12

Use Code Sections with Control Statements and

Functions 17-12 Scripts vs Functions 17-16

Function Basics

18

Create Functions in Files 18-2 Add Help for Your Program 18-5 Run Functions in the Editor 18-7 Base and Function Workspaces 18-9 Share Data Between Workspaces 18-10

Use Automatic Function and Variable Highlighting 18-15

Example of Using Automatic Function and Variable

Highlighting 18-16 Types of Functions 18-19

Local and Nested Functions in a File 18-19

Private Functions in a Subfolder 18-20

Anonymous Functions Without a File 18-20

Trang 20

Functions with Multiple Inputs or Outputs 18-26

Arrays of Anonymous Functions 18-27 Local Functions 18-29 Nested Functions 18-31

What Are Nested Functions? 18-31

Requirements for Nested Functions 18-31

Sharing Variables Between Parent and NestedFunctions 18-32

Using Handles to Store Function Parameters 18-33

Visibility of Nested Functions 18-36 Variables in Nested and Anonymous Functions 18-38 Private Functions 18-40 Function Precedence Order 18-42

Function Arguments

19

Find Number of Function Arguments 19-2 Support Variable Number of Inputs 19-4 Support Variable Number of Outputs 19-6

Trang 21

Debugging MATLAB Code

20

Debug a MATLAB Program 20-2

Set Breakpoint 20-2

Find and Fix a Problem 20-4

Step Through File 20-6

End Debugging Session 20-7 Set Breakpoints 20-8

Select Workspace 20-17

View Variable Value 20-17

Presenting MATLAB Code

21

Options for Presenting Your Code 21-2 Document and Share Code Using Examples 21-4 Publishing MATLAB Code 21-7 Publishing Markup 21-9

Trang 22

How to Edit Publishing Options 21-29

Specify Output File 21-30

Run Code During Publishing 21-31

Manipulate Graphics in Publishing Output 21-33

Save a Publish Setting 21-37

Manage a Publish Configuration 21-39 Create a MATLAB Notebook with Microsoft Word 21-43

Getting Started with MATLAB Notebooks 21-43

Creating and Evaluating Cells in a MATLABNotebook 21-45

Formatting a MATLAB Notebook 21-50

Tips for Using MATLAB Notebooks 21-52

Configuring the MATLAB Notebook Software 21-53

Coding and Productivity Tips

22

Open and Save Files 22-2

Open Existing Files 22-2

Save Files 22-3

Trang 23

Enable MATLAB Compiler Deployment Messages 22-19 Improve Code Readability 22-21

Indenting Code 22-21

Right-Side Text Limit Indicator 22-23

Code Folding — Expand and Collapse Code

Constructs 22-23 Find and Replace Text in Files 22-28

Find Any Text in the Current File 22-28

Find and Replace Functions or Variables in the Current

File 22-28

Automatically Rename All Functions or Variables in a

File 22-30

Find and Replace Any Text 22-32

Find Text in Multiple File Names or Files 22-32

Function Alternative for Finding Text 22-32

Perform an Incremental Search in the Editor 22-32

Go To Location in File 22-33

Navigate to a Specific Location 22-33

Set Bookmarks 22-36

Navigate Backward and Forward in Files 22-36

Open a File or Variable from Within a File 22-37 Display Two Parts of a File Simultaneously 22-39 Add Reminders to Files 22-41

Working with TODO/FIXME Reports 22-41 Colors in the MATLAB Editor 22-44 Code Contains %#ok — What Does That Mean? 22-46 MATLAB Code Analyzer Report 22-47

Running the Code Analyzer Report 22-47

Changing Code Based on Code Analyzer Messages 22-49

Other Ways to Access Code Analyzer Messages 22-50

Trang 24

Programming Utilities

23

Identify Program Dependencies 23-2

Simple Display of Program File Dependencies 23-2

Detailed Display of Program File Dependencies 23-2

Dependencies Within a Folder 23-3 Protect Your Source Code 23-7

Building a Content Obscured Format with P-Code 23-7

Building a Standalone Executable 23-8 Create Hyperlinks that Run Functions 23-10

Run a Single Function 23-11

Run Multiple Functions 23-11

Provide Command Options 23-12

Include Special Characters 23-12 Create and Share Toolboxes 23-13

Create Toolbox 23-13

Share Toolbox 23-16

Software Development

Error Handling

Trang 25

The MException Class 24-5

Properties of the MException Class 24-7

Methods of the MException Class 24-13 Throw an Exception 24-15 Respond to an Exception 24-17

Overview 24-17

The try/catch Statement 24-17

Suggestions on How to Handle an Exception 24-19 Clean Up When Functions Complete 24-22

Overview 24-22

Examples of Cleaning Up a Program Upon Exit 24-23

Retrieving Information About the Cleanup Routine 24-25

Using onCleanup Versus try/catch 24-26

onCleanup in Scripts 24-27 Issue Warnings and Errors 24-28

Disable and Restore a Particular Warning 24-34

Disable and Restore Multiple Warnings 24-35 Change How Warnings Display 24-37

Enable Verbose Warnings 24-37

Display a Stack Trace on a Specific Warning 24-38 Use try/catch to Handle Errors 24-39

Trang 26

Overview 25-2

Example: Displaying a Message 25-3 Timer Callback Functions 25-5

Associating Commands with Timer Object Events 25-5

Creating Callback Functions 25-6

Specifying the Value of Callback Function Properties 25-8 Handling Timer Queuing Conflicts 25-10

Drop Mode (Default) 25-10

Error Mode 25-12

Queue Mode 25-13

Performance

26

Measure Performance of Your Program 26-2

Overview of Performance Timing Functions 26-2

Time Functions 26-2

Time Portions of Code 26-2

The cputime Function vs tic/toc and timeit 26-3

Tips for Measuring Performance 26-3 Profile to Improve Performance 26-5

What Is Profiling? 26-5

Profiling Process and Guidelines 26-5

Using the Profiler 26-6

Profile Summary Report 26-8

Profile Detail Report 26-10

Trang 27

Preallocating a Nondouble Matrix 26-18 Vectorization 26-20

Using Vectorization 26-20

Array Operations 26-21

Logical Array Operations 26-22

Matrix Operations 26-23

Ordering, Setting, and Counting Operations 26-25

Functions Commonly Used in Vectorization 26-26

Memory Usage

27

Memory Allocation 27-2

Memory Allocation for Arrays 27-2

Data Structures and Memory 27-6 Memory Management Functions 27-11

The whos Function 27-12 Strategies for Efficient Use of Memory 27-14

Ways to Reduce the Amount of Memory Required 27-14

Using Appropriate Data Storage 27-16

How to Avoid Fragmenting Memory 27-18

Reclaiming Used Memory 27-20 Resolving “Out of Memory” Errors 27-21

General Suggestions for Reclaiming Memory 27-21

Setting the Process Limit 27-21

Disabling Java VM on Startup 27-23

Increasing System Swap Space 27-23

Using the 3GB Switch on Windows Systems 27-24

Freeing Up System Resources on Windows Systems 27-24

Trang 28

Help Text from the doc Command 28-2

Custom Help Text 28-3 Check Which Programs Have Help 28-9 Create Help Summary Files — Contents.m 28-12

What Is a Contents.m File? 28-12

Create a Contents.m File 28-13

Check an Existing Contents.m File 28-13 Display Custom Documentation 28-15

Overview 28-15

Identify Your Documentation — info.xml 28-16

Create a Table of Contents — helptoc.xml 28-18

Build a Search Database 28-20

Address Validation Errors for info.xml Files 28-21 Display Custom Examples 28-23

How to Display Examples 28-23

Elements of the demos.xml File 28-24

Source Control Interface

29

About MathWorks Source Control Integration 29-2

Classic and Distributed Source Control 29-2 Select or Disable Source Control System 29-5

Trang 29

Resolve Conflicts 29-10

Merge Text Files 29-11

Extract Conflict Markers 29-12 Commit Modified Files to Source Control 29-14 Revert Changes in Source Control 29-15

Revert Local Changes 29-15

Revert a File to a Specified Revision 29-15 Set Up SVN Source Control 29-16

SVN Source Control Options 29-16

Register Binary Files with SVN 29-17

Standard Repository Structure 29-20

Tag Versions of Files 29-20

Enforce Locking Files Before Editing 29-21

Share a Subversion Repository 29-21 Check Out from SVN Repository 29-23

Retrieve Tagged Version of Repository 29-25 Update SVN File Status and Revision 29-27

Refresh Status of Files 29-27

Update Revisions of Files 29-27 Get SVN File Locks 29-28 Set Up Git Source Control 29-29

About Git Source Control 29-29

Install Command-Line Git Client 29-30

Register Binary Files with Git 29-31 Clone from Git Repository 29-34

Troubleshooting 29-35 Update Git File Status and Revision 29-36

Refresh Status of Files 29-36

Update Revisions of Files 29-36

Trang 30

Delete Branches 29-40 Push and Fetch with Git 29-41

Push 29-41

Fetch 29-42 MSSCCI Source Control Interface 29-43 Set Up MSSCCI Source Control 29-44

Create Projects in Source Control System 29-44

Specify Source Control System with MATLABSoftware 29-46

Register Source Control Project with MATLABSoftware 29-47

Add Files to Source Control 29-49 Check Files In and Out from MSSCCI Source Control 29-51

Check Files Into Source Control 29-51

Check Files Out of Source Control 29-52

Undoing the Checkout 29-53 Additional MSSCCI Source Control Actions 29-54

Getting the Latest Version of Files for Viewing orCompiling 29-54

Removing Files from the Source Control System 29-55

Showing File History 29-56

Comparing the Working Copy of a File to the LatestVersion in Source Control 29-57

Viewing Source Control Properties of a File 29-59

Starting the Source Control System 29-59

Trang 31

Create Test Function 30-13

Run the Tests 30-16

Analyze the Results 30-16 Write Simple Test Case Using Functions 30-17 Write Test Using Setup and Teardown Functions 30-22 Additional Topics for Function-Based Tests 30-29

Fixtures for Setup and Teardown Code 30-29

Test Logging and Verbosity 30-30

Test Suite Creation 30-31

Test Selection 30-31

Test Running 30-32

Test Runner Customization 30-32 Author Class-Based Unit Tests in MATLAB 30-34

The Test Class Definition 30-34

The Unit Tests 30-34

Additional Features for Advanced Test Classes 30-36 Write Simple Test Case Using Classes 30-38 Write Setup and Teardown Code Using Classes 30-43

Test Fixtures 30-43

Test Case with Method-Level Setup Code 30-43

Trang 32

Write Tests Using Shared Fixtures 30-55 Create Basic Custom Fixture 30-59 Create Advanced Custom Fixture 30-62 Create Basic Parameterized Test 30-69 Create Advanced Parameterized Test 30-75 Create Simple Test Suites 30-83 Run Tests for Various Workflows 30-86

Set Up Example Tests 30-86

Run All Tests in Class or Function 30-86

Run Single Test in Class or Function 30-87

Run Test Suites by Name 30-87

Run Test Suites from Test Array 30-88

Run Tests with Customized Test Runner 30-88 Add Plugin to Test Runner 30-90 Write Plugins to Extend TestRunner 30-93

Custom Plugins Overview 30-93

Extending Test Level Plugin Methods 30-94

Extending Test Class Level Plugin Methods 30-94

Extending Test Suite Level Plugin Methods 30-95 Create Custom Plugin 30-97

Trang 33

Create Custom Constraint 30-126 Create Custom Boolean Constraint 30-129 Create Custom Tolerance 30-132

Trang 37

Syntax Basics

• “Create Variables” on page 1-2

• “Create Numeric Arrays” on page 1-3

• “Continue Long Statements on Multiple Lines” on page 1-5

• “Call Functions” on page 1-6

• “Ignore Function Outputs” on page 1-7

• “Variable Names” on page 1-8

• “Case and Space Sensitivity” on page 1-10

• “Command vs Function Syntax” on page 1-12

• “Common Errors When Calling Functions” on page 1-16

Trang 38

You do not have to declare variables before assigning values.

If you do not end an assignment statement with a semicolon (;), MATLAB® displays theresult in the Command Window For example,

Trang 39

Create Numeric Arrays

This example shows how to create a numeric variable In the MATLAB computing

environment, all variables are arrays, and by default, numeric variables are of typedouble (that is, double-precision values) For example, create a scalar value

Trang 40

• “Matrix Indexing”

Ngày đăng: 06/02/2016, 08:23

TỪ KHÓA LIÊN QUAN