MATLAB Programming Fundamentals

780 135 10MB

English Pages [1560] Year 2022

Report DMCA / Copyright

DOWNLOAD FILE

MATLAB Programming Fundamentals

Table of contents :
Language
Syntax Basics
Continue Long Statements on Multiple Lines
Name=Value in Function Calls
Ignore Function Outputs
Variable Names
Valid Names
Conflicts with Function Names
Case and Space Sensitivity
Choose Command Syntax or Function Syntax
Command Syntax and Function Syntax
Avoid Common Syntax Mistakes
How MATLAB Recognizes Command Syntax
Resolve Error: Undefined Function or Variable
Issue
Possible Solutions
Program Components
MATLAB Operators and Special Characters
Arithmetic Operators
Relational Operators
Logical Operators
Special Characters
String and Character Formatting
Array vs. Matrix Operations
Introduction
Array Operations
Matrix Operations
Compatible Array Sizes for Basic Operations
Inputs with Compatible Sizes
Inputs with Incompatible Sizes
Examples
Array Comparison with Relational Operators
Array Comparison
Logic Statements
Operator Precedence
Precedence of AND and OR Operators
Overriding Default Precedence
Average Similar Data Points Using a Tolerance
Group Scattered Data Using a Tolerance
Bit-Wise Operations
Perform Cyclic Redundancy Check
Conditional Statements
Loop Control Statements
Regular Expressions
What Is a Regular Expression?
Steps for Building Expressions
Operators and Characters
Lookahead Assertions in Regular Expressions
Lookahead Assertions
Overlapping Matches
Logical AND Conditions
Tokens in Regular Expressions
Introduction
Multiple Tokens
Unmatched Tokens
Tokens in Replacement Text
Named Capture
Dynamic Regular Expressions
Introduction
Dynamic Match Expressions — (??expr)
Commands That Modify the Match Expression — (??@cmd)
Commands That Serve a Functional Purpose — (?@cmd)
Commands in Replacement Expressions — ${cmd}
Comma-Separated Lists
What Is a Comma-Separated List?
Generating a Comma-Separated List
Assigning Output from a Comma-Separated List
Assigning to a Comma-Separated List
How to Use Comma-Separated Lists
Fast Fourier Transform Example
Troubleshooting Operations with Comma-Separated Lists
Alternatives to the eval Function
Why Avoid the eval Function?
Variables with Sequential Names
Files with Sequential Names
Function Names in Variables
Field Names in Variables
Error Handling
Classes (Data Types)
Overview of MATLAB Classes
Fundamental MATLAB Classes
Detect States of Variables Using is* Functions
Numeric Classes
Integers
Integer Classes
Creating Integer Data
Arithmetic Operations on Integer Classes
Largest and Smallest Values for Integer Classes
Floating-Point Numbers
Double-Precision Floating Point
Single-Precision Floating Point
Creating Floating-Point Data
Arithmetic Operations on Floating-Point Numbers
Largest and Smallest Values for Floating-Point Classes
Accuracy of Floating-Point Data
Avoiding Common Problems with Floating-Point Arithmetic
Create Complex Numbers
Infinity and NaN
Infinity
NaN
Identifying Numeric Classes
Display Format for Numeric Values
Integer Arithmetic
Single Precision Math
The Logical Class
Find Array Elements That Meet a Condition
Reduce Logical Arrays to Single Value
Characters and Strings
Text in String and Character Arrays
Create String Arrays
Cell Arrays of Character Vectors
Create Cell Array of Character Vectors
Access Character Vectors in Cell Array
Convert Cell Arrays to String Arrays
Analyze Text Data with String Arrays
Test for Empty Strings and Missing Values
Formatting Text
Fields of the Formatting Operator
Setting Field Width and Precision
Restrictions on Using Identifiers
Compare Text
Search and Replace Text
Build Pattern Expressions
Convert Numeric Values to Text
Convert Text to Numeric Values
Unicode and ASCII Values
Hexadecimal and Binary Values
Frequently Asked Questions About String Arrays
Why Does Using Command Form With Strings Return An Error?
Why Do Strings in Cell Arrays Return an Error?
Why Does length() of String Return 1?
Why Does isempty("") Return 0?
Why Does Appending Strings Using Square Brackets Return Multiple Strings?
Update Your Code to Accept Strings
What Are String Arrays?
Recommended Approaches for String Adoption in Old APIs
How to Adopt String Arrays in Old APIs
Recommended Approaches for String Adoption in New Code
How to Maintain Compatibility in New Code
How to Manually Convert Input Arguments
How to Check Argument Data Types
Terminology for Character and String Arrays
Dates and Time
Represent Dates and Times in MATLAB
Specify Time Zones
Convert Date and Time to Julian Date or POSIX Time
Set Date and Time Display Format
Formats for Individual Date and Duration Arrays
datetime Display Format
duration Display Format
calendarDuration Display Format
Default datetime Format
Generate Sequence of Dates and Time
Sequence of Datetime or Duration Values Between Endpoints with Step Size
Add Duration or Calendar Duration to Create Sequence of Dates
Specify Length and Endpoints of Date or Duration Sequence
Sequence of Datetime Values Using Calendar Rules
Share Code and Data Across Locales
Write Locale-Independent Date and Time Code
Write Dates in Other Languages
Read Dates in Other Languages
Extract or Assign Date and Time Components of Datetime Array
Combine Date and Time from Separate Variables
Date and Time Arithmetic
Compare Dates and Time
Plot Dates and Times
Core Functions Supporting Date and Time Arrays
Convert Between Text and datetime or duration Values
Replace Discouraged Instances of Serial Date Numbers and Date Strings
Convert Serial Date Numbers and Date Strings
Replace Functions That Use Date Numbers
Discouraged Syntaxes for Date and Time Components
Guidelines for Updating Your Own Functions
Carryover in Date Vectors and Strings
Converting Date Vector Returns Unexpected Output
Categorical Arrays
Create Categorical Arrays
Convert Text in Table Variables to Categorical
Plot Categorical Data
Compare Categorical Array Elements
Combine Categorical Arrays
Combine Categorical Arrays Using Multiplication
Access Data Using Categorical Arrays
Select Data By Category
Common Ways to Access Data Using Categorical Arrays
Work with Protected Categorical Arrays
Advantages of Using Categorical Arrays
Natural Representation of Categorical Data
Mathematical Ordering for Character Vectors
Reduce Memory Requirements
Ordinal Categorical Arrays
Order of Categories
How to Create Ordinal Categorical Arrays
Working with Ordinal Categorical Arrays
Core Functions Supporting Categorical Arrays
Tables
Create Tables and Assign Data to Them
Add and Delete Table Rows
Add, Delete, and Rearrange Table Variables
Clean Messy and Missing Data in Tables
Modify Units, Descriptions, and Table Variable Names
Add Custom Properties to Tables and Timetables
Access Data in Tables
Summary of Table Indexing Syntaxes
Table Indexing with Specified Rows and Variables
Find Rows Where Values Meet Logical Conditions
Dot Notation with Any Variable Name or Expression
Extract Data from Specified Rows and Variables
Calculations on Data in Tables
Split Data into Groups and Calculate Statistics
Perform Calculations by Group in Table
Advantages of Using Tables
Grouping Variables To Split Data
Grouping Variables
Group Definition
The Split-Apply-Combine Workflow
Missing Group Values
Changes to DimensionNames Property in R2016b
Data Cleaning and Calculations in Tables
Grouped Calculations in Tables and Timetables
Timetables
Create Timetables
Resample and Aggregate Data in Timetable
Combine Timetables and Synchronize Their Data
Retime and Synchronize Timetable Variables Using Different Methods
Select Times in Timetable
Clean Timetable with Missing, Duplicate, or Nonuniform Times
Using Row Labels in Table and Timetable Operations
Loma Prieta Earthquake Analysis
Preprocess and Explore Time-Stamped Data Using timetable
Add Events from External Data to Timetable
Find Events in Timestamped Data
Structures
Structure Arrays
Create Scalar Structure
Access Values in Fields
Index into Nonscalar Structure Array
Concatenate Structures
Generate Field Names from Variables
Access Data in Nested Structures
Access Elements of a Nonscalar Structure Array
Ways to Organize Data in Structure Arrays
Plane Organization
Element-by-Element Organization
Memory Requirements for Structure Array
Cell Arrays
What Is a Cell Array?
Create Cell Array
Access Data in Cell Array
Add Cells to Cell Array
Delete Data from Cell Array
Combine Cell Arrays
Pass Contents of Cell Arrays to Functions
Preallocate Memory for Cell Array
Cell vs. Structure Arrays
Multilevel Indexing to Access Parts of Cells
Function Handles
Create Function Handle
What Is a Function Handle?
Creating Function Handles
Anonymous Functions
Arrays of Function Handles
Saving and Loading Function Handles
Pass Function to Another Function
Call Local Functions Using Function Handles
Compare Function Handles
Dictionaries
Map Data with Dictionaries
Dictionaries and Custom Classes
Hash Equivalence
Overload keyHash and keyMatch for Custom Classes
Map Containers
Overview of Map Data Structure
Description of Map Class
Properties of Map Class
Methods of Map Class
Create Map Object
Construct Empty Map Object
Construct Initialized Map Object
Combine Map Objects
Examine Contents of Map
Read and Write Using Key Index
Read From Map
Add Key/Value Pairs
Build Map with Concatenation
Modify Keys and Values in Map
Remove Keys and Values from Map
Modify Values
Modify Keys
Modify Copy of Map
Map to Different Value Types
Map to Structure Array
Map to Cell Array
Combining Unlike Classes
Valid Combinations of Unlike Classes
Combining Unlike Integer Types
Overview
Example of Combining Unlike Integer Sizes
Example of Combining Signed with Unsigned
Combining Integer and Noninteger Data
Combining Cell Arrays with Non-Cell Arrays
Empty Matrices
Concatenation Examples
Combining Single and Double Types
Combining Integer and Double Types
Combining Character and Double Types
Combining Logical and Double Types
Using Objects
Copying Objects
Two Copy Behaviors
Handle Object Copy
Value Object Copy Behavior
Handle Object Copy Behavior
Testing for Handle or Value Class
Defining Your Own Classes
Scripts and Functions
Scripts
Create Scripts
Add Comments to Code
Create and Run Sections in Code
Divide Your File into Sections
Run Sections
Navigate Between Sections
Behavior of Sections in Functions
Behavior of Sections in Loops and Conditional Statements
Scripts vs. Functions
Add Functions to Scripts
Create a Script with Local Functions
Run Scripts with Local Functions
Restrictions for Local Functions and Variables
Access Help for Local Functions
Live Scripts and Functions
What Is a Live Script or Function?
Differences with Plain Code Scripts and Functions
Requirements
Unsupported Features
Create Live Scripts in the Live Editor
Create Live Script
Add Code
Run Code
Display Output
Change View
Format Text
Save Live Scripts as Plain Code
Modify Figures in Live Scripts
Explore Data
Add Formatting and Annotations
Update Code with Figure Changes
Save and Print Figure
Format Text in the Live Editor
Change Fonts
Autoformatting
Insert Equations into the Live Editor
Insert Equation Interactively
Insert LaTeX Equation
Supported LaTeX Commands
Add Interactive Controls to a Live Script
Insert Controls
Modify Control Labels
Link Variables to Controls
Specify Default Values
Modify Control Execution
Create Live Script with Multiple Interactive Controls
Share Live Script
Add Interactive Tasks to a Live Script
What Are Live Editor Tasks?
Insert Tasks
Run Tasks and Surrounding Code
Modify Output Argument Name
View and Edit Generated Code
Custom Live Editor Tasks
Create Live Functions
Create Live Function
Add Code
Add Help
Run Live Function
Save Live Functions as Plain Code
Add Help for Live Functions
Share Live Scripts and Functions
Hide Code Before Sharing
Live Code File Format (.mlx)
Benefits of Live Code File Format
Source Control
Introduction to the Live Editor
Accelerate Exploratory Programming Using the Live Editor
Create an Interactive Narrative with the Live Editor
Create Interactive Course Materials Using the Live Editor
Create Examples Using the Live Editor
Create an Interactive Form Using the Live Editor
Create a Real-Time Dashboard Using the Live Editor
Acknowledgments
Function Basics
Create Functions in Files
Syntax for Function Definition
Contents of Functions and Files
End Statements
Add Help for Your Program
Configure the Run Button for Functions
Base and Function Workspaces
Share Data Between Workspaces
Introduction
Best Practice: Passing Arguments
Nested Functions
Persistent Variables
Global Variables
Evaluating in Another Workspace
Check Variable Scope in Editor
Use Automatic Function and Variable Highlighting
Example of Using Automatic Function and Variable Highlighting
Types of Functions
Local and Nested Functions in a File
Private Functions in a Subfolder
Anonymous Functions Without a File
Anonymous Functions
What Are Anonymous Functions?
Variables in the Expression
Multiple Anonymous Functions
Functions with No Inputs
Functions with Multiple Inputs or Outputs
Arrays of Anonymous Functions
Local Functions
Nested Functions
What Are Nested Functions?
Requirements for Nested Functions
Sharing Variables Between Parent and Nested Functions
Using Handles to Store Function Parameters
Visibility of Nested Functions
Resolve Error: Attempt to Add Variable to a Static Workspace.
Issue
Possible Solutions
Private Functions
Function Precedence Order
Change in Rules For Function Precedence Order
Update Code for R2019b Changes to Function Precedence Order
Identifiers cannot be used for two purposes inside a function
Identifiers without explicit declarations might not be treated as variables
Variables cannot be implicitly shared between parent and nested functions
Change in precedence of wildcard-based imports
Fully qualified import functions cannot have the same name as nested functions
Fully qualified imports shadow outer scope definitions of the same name
Error handling when import not found
Nested functions inherit import statements from parent functions
Change in precedence of compound name resolution
Anonymous functions can include resolved and unresolved identifiers
Indexing into Function Call Results
Example
Supported Syntaxes
Function Arguments
Find Number of Function Arguments
Support Variable Number of Inputs
Support Variable Number of Outputs
Validate Number of Function Arguments
Checking Number of Arguments in Nested Functions
Ignore Inputs in Function Definitions
Check Function Inputs with validateattributes
Parse Function Inputs
Input Parser Validation Functions
Debugging MATLAB Code
Debug MATLAB Code Files
Display Output
Debug Using Run to Here
View Variable Value While Debugging
Pause a Running File
Step Into Functions
Add Breakpoints and Run Code
End Debugging Session
Debug by Using Keyboard Shortcuts or Functions
Set Breakpoints
Standard Breakpoints
Conditional Breakpoints
Error Breakpoints
Breakpoints in Anonymous Functions
Invalid Breakpoints
Disable Breakpoints
Clear Breakpoints
Examine Values While Debugging
View Variable Value
View Variable Value Outside Current Workspace
Presenting MATLAB Code
Publish and Share MATLAB Code
Create and Share Live Scripts in the Live Editor
Publish MATLAB Code Files (.m)
Add Help and Create Documentation
Publishing Markup
Markup Overview
Sections and Section Titles
Text Formatting
Bulleted and Numbered Lists
Text and Code Blocks
External File Content
External Graphics
Image Snapshot
LaTeX Equations
Hyperlinks
HTML Markup
LaTeX Markup
Output Preferences for Publishing
How to Edit Publishing Options
Specify Output File
Run Code During Publishing
Manipulate Graphics in Publishing Output
Save a Publish Setting
Manage a Publish Configuration
Coding and Productivity Tips
Save and Back Up Code
Save Code
Back Up Code
Recommendations on Saving Files
File Encoding
Check Code for Errors and Warnings Using the Code Analyzer
Enable Continuous Code Checking
View Code Analyzer Status for File
View Code Analyzer Messages
Fix Problems in Code
Create a Code Analyzer Message Report
Adjust Code Analyzer Message Indicators and Messages
Understand Code Containing Suppressed Messages
Understand the Limitations of Code Analysis
Enable MATLAB Compiler Deployment Messages
Edit and Format Code
Column Selection
Change Case
Automatically Complete Code
Refactor Code
Indent Code
Fold Code
Change the Right-Side Text Limit Indicator
Find and Replace Text in Files and Go to Location
Find and Replace Any Text in Current File
Find and Replace Functions or Variables in Current File
Automatically Rename All Variables or Functions in a File
Find Text in Multiple File Names or Files
Go To Location in File
Add Reminders to Files
Working with TODO/FIXME Reports
MATLAB Code Analyzer Report
Run the Code Analyzer Report
Change Code Based on Code Analyzer Messages
Other Ways to Access Code Analyzer Messages
MATLAB Code Compatibility Analyzer
Open the Code Compatibility Analyzer
Programmatic Use
Unsupported Functionality
Code Generation Readiness Tool
Issues Tab
Files Tab
Programming Utilities
Identify Program Dependencies
Simple Display of Program File Dependencies
Detailed Display of Program File Dependencies
Dependencies Within a Folder
Security Considerations to Protect Your Source Code
Create P-Code Files
Build Standalone Executables
Use Model Protection
Convert Code to Native Code
Host Compiled Application on Remote Protected Server
Utilize Secure OS Services
Create a Content-Obscured File with P-Code
Create P-Code Files
Invoke P-Code Files
Run Older P-Code Files on Later Versions of MATLAB
Create Hyperlinks that Run Functions
Run a Single Function
Run Multiple Functions
Provide Command Options
Include Special Characters
Create and Share Toolboxes
Create Toolbox
Share Toolbox
Run Parallel Language in MATLAB
Run Parallel Language in Serial
Use Parallel Language Without a Pool
Function Argument Validation
Function Argument Validation
Introduction to Argument Validation
Where to Use Argument Validation
arguments Block Syntax
Examples of Argument Validation
Kinds of Arguments
Required and Optional Positional Arguments
Repeating Arguments
Name-Value Arguments
Robust Handling of Name-Value Arguments
Name-Value Arguments from Class Properties
Order of Argument Validation
Avoiding Class and Size Conversions
nargin in Argument Validation
Restrictions on Variable and Function Access
Debugging Arguments Blocks
Argument Validation Functions
Numeric Value Attributes
Comparison with Other Values
Data Types
Size
Membership and Range
Text
Define Validation Functions
Transparency in MATLAB Code
Writing Transparent Code
Software Development
Error Handling
Exception Handling in a MATLAB Application
Overview
Getting an Exception at the Command Line
Getting an Exception in Your Program Code
Generating a New Exception
Throw an Exception
Suggestions on How to Throw an Exception
Respond to an Exception
Overview
The try/catch Statement
Suggestions on How to Handle an Exception
Clean Up When Functions Complete
Overview
Examples of Cleaning Up a Program Upon Exit
Retrieving Information About the Cleanup Routine
Using onCleanup Versus try/catch
onCleanup in Scripts
Issue Warnings and Errors
Issue Warnings
Throw Errors
Add Run-Time Parameters to Your Warnings and Errors
Add Identifiers to Warnings and Errors
Suppress Warnings
Turn Warnings On and Off
Restore Warnings
Disable and Restore a Particular Warning
Disable and Restore Multiple Warnings
Change How Warnings Display
Enable Verbose Warnings
Display a Stack Trace on a Specific Warning
Use try/catch to Handle Errors
Program Scheduling
Schedule Command Execution Using Timer
Overview
Example: Displaying a Message
Timer Callback Functions
Associating Commands with Timer Object Events
Creating Callback Functions
Specifying the Value of Callback Function Properties
Handling Timer Queuing Conflicts
Drop Mode (Default)
Error Mode
Queue Mode
Performance
Measure the Performance of Your Code
Overview of Performance Timing Functions
Time Functions
Time Portions of Code
The cputime Function vs. tic/toc and timeit
Tips for Measuring Performance
Profile Your Code to Improve Performance
What Is Profiling?
Profile Your Code
Profile Multiple Statements in Command Window
Profile an App
Techniques to Improve Performance
Environment
Code Structure
Programming Practices for Performance
Tips on Specific MATLAB Functions
Preallocation
Preallocating a Nondouble Matrix
Vectorization
Using Vectorization
Array Operations
Logical Array Operations
Matrix Operations
Ordering, Setting, and Counting Operations
Functions Commonly Used in Vectorization
Background Processing
Asynchronous Functions
Asynchronous Code
Background Workers
Run MATLAB Functions in Thread-Based Environment
Run Functions in the Background
Run Functions on a Thread Pool
Automatically Scale Up
Check Thread Supported Functions
Create Responsive Apps by Running Calculations in the Background
Open App Designer App
Add a Future Array to the Properties
Create y-axis Data in the Background
Automatically Update Plot After Data Is Calculated in the Background
Make Your App More Responsive by Canceling the Future Array
Responsive App That Calculates and Plots Simple Curves
Run Functions in Background
Update Wait Bar While Functions Run in the Background
Memory Usage
Strategies for Efficient Use of Memory
Use Appropriate Data Storage
Avoid Temporary Copies of Data
Reclaim Used Memory
Resolve “Out of Memory” Errors
Issue
Possible Solutions
How MATLAB Allocates Memory
Avoid Unnecessary Copies of Data
Passing Values to Functions
Why Pass-by-Value Semantics
Handle Objects
Custom Help and Documentation
Create Help for Classes
Help Text from the doc Command
Custom Help Text
Check Which Programs Have Help
Create Help Summary Files — Contents.m
What Is a Contents.m File?
Create a Contents.m File
Check an Existing Contents.m File
Customize Code Suggestions and Completions
Function Objects
Signature Objects
Argument Objects
Create Function Signature File
How Function Signature Information is Used
Multiple Signatures
Display Custom Documentation
Overview
Create HTML Help Files
Create info.xml File
Create helptoc.xml File
Build a Search Database
Address Validation Errors for info.xml Files
Display Custom Examples
How to Display Examples
Elements of the demos.xml File
Projects
Create Projects
What Are Projects?
Create Project
Open Project
Set up Project
Add Files to Project
Other Ways to Create Projects
Automate Startup and Shutdown Tasks
Specify Project Path
Set Startup Folder
Specify Startup and Shutdown Files
Set MATLAB Projects Preferences
Determine Order for Resolving Conflicts Using Dependency Analyzer
Manage Project Files
Automatic Updates When Renaming, Deleting, or Removing Files
Find Project Files
Group and Sort Project Files
Search for and Filter Project Files
Search the Content in Project Files
Create Shortcuts to Frequent Tasks
Run Shortcuts
Create Shortcuts
Organize Shortcuts
Add Labels to Project Files
Add Labels
View and Edit Label Data
Create Labels
Create Custom Tasks
Create a Custom Task Function
Run a Custom Task
Save Custom Task Report
Componentize Large Projects
Add or Remove Reference to a Project
View, Edit, or Run Referenced Project Files
Extract Folder to Create a Referenced Project
Manage Changes in Referenced Project Using Checkpoints
Share Projects
Create an Export Profile
Upgrade Projects
Run Upgrade Project Tool
Examine Upgrade Project Report
Analyze Project Dependencies
Run a Dependency Analysis
Explore the Dependency Graph, Views, and Filters
Investigate and Resolve Problems
Find Required Products and Add-Ons
Find File Dependencies
Export Dependency Analysis Results
Clone Remote Git Repository into New Project
Use Source Control with Projects
Setup Source Control
Perform Source Control Operations
Work with Derived Files in Projects
Find Project Files With Unsaved Changes
Manage Open Files When Closing a Project
Create and Edit Projects Programmatically
Explore an Example Project
Source Control Interface
Source Control Integration in MATLAB
Classic and Distributed Source Control
Set Source Control Preferences
Set Git Preferences in MATLAB Online
Use Git in MATLAB
Clone Remote Git Repository
Mark Files for Addition
Review Changes
Commit Modified Files
Push Files
Resolve Conflicts
Manage Files
Create Local Git Repository
Store Uncommitted Changes Using Git Stashes
Set Up Git Source Control
Register Binary Files with Git
Configure MATLAB for Git on Windows
Configure MATLAB to Use Git SSH Authentication
Install Git Credential Helper
Disable Compression for Simulink Models
Configure Git to Use Git LFS
Configure Git to use MATLAB for Diff and Merge
Install Command-Line Git Client
Branch and Merge with Git
Create Branch
Switch Branch
Compare Branches
Merge Branches
Revert to Head
Delete Branches
Add Git Submodules
Update Submodules
Use Fetch and Merge with Submodules
Use Push to Send Changes to the Submodule Repository
Review Changes in SVN Source Control
Mark Files for Addition to SVN Source Control
Move, Rename, or Delete Files Under SVN Source Control
Resolve SVN Source Control Conflicts
Examining and Resolving Conflicts
Resolve Conflicts
Merge Text Files
Extract Conflict Markers
Commit Modified Files to SVN Source Control
Revert Changes in SVN Source Control
Revert Local Changes
Revert a File to a Specified Revision
Set Up SVN Source Control
SVN Source Control Options
Register Binary Files with SVN
Standard Repository Structure
Tag Versions of Files
Enforce Locking Files Before Editing
Share a Subversion Repository
Check Out from SVN Repository
Retrieve Tagged Version of Repository
Update SVN File Status and Revision
Refresh Status of Files
Update Revisions of Files
Get SVN File Locks
Manage SVN Repository Locks
Continuous Integration Using MATLAB Projects and Jenkins
Prerequisites
Set Up MATLAB Project for Continuous Integration in Jenkins
Reduce Test Runtime Using Dependency Cache and Impact Analysis
Enhance Workflow
Customize External Source Control to Use MATLAB for Diff and Merge
Finding the Full Paths for MATLAB Diff, Merge, and AutoMerge
Integration with Git
Integration with SVN
Integration with Other Source Control Tools
MSSCCI Source Control Interface
Set Up MSSCCI Source Control
Create Projects in Source Control System
Specify Source Control System with MATLAB Software
Register Source Control Project with MATLAB Software
Add Files to Source Control
Check Files In and Out from MSSCCI Source Control
Check Files Into Source Control
Check Files Out of Source Control
Undoing the Checkout
Additional MSSCCI Source Control Actions
Getting the Latest Version of Files for Viewing or Compiling
Removing Files from the Source Control System
Showing File History
Comparing the Working Copy of a File to the Latest Version in Source Control
Viewing Source Control Properties of a File
Starting the Source Control System
Access MSSCCI Source Control from Editors
Troubleshoot MSSCCI Source Control Problems
Source Control Error: Provider Not Present or Not Installed Properly
Restriction Against @ Character
Add to Source Control Is the Only Action Available
More Solutions for Source Control Problems
Unit Testing
Write Test Using Live Script
Write Script-Based Unit Tests
Write Script-Based Test Using Local Functions
Extend Script-Based Tests
Test Suite Creation
Test Selection
Programmatic Access of Test Diagnostics
Test Runner Customization
Run Tests in Editor
Write Function-Based Unit Tests
Create Test Function
Run the Tests
Analyze the Results
Write Simple Test Case Using Functions
Write Test Using Setup and Teardown Functions
Extend Function-Based Tests
Fixtures for Setup and Teardown Code
Test Logging and Verbosity
Test Suite Creation
Test Selection
Test Running
Programmatic Access of Test Diagnostics
Test Runner Customization
Author Class-Based Unit Tests in MATLAB
The Test Class Definition
The Unit Tests
Additional Features for Advanced Test Classes
Write Simple Test Case Using Classes
Write Setup and Teardown Code Using Classes
Test Fixtures
Test Case with Method-Level Setup Code
Test Case with Class-Level Setup Code
Table of Verifications, Assertions, and Other Qualifications
Tag Unit Tests
Tag Tests
Select and Run Tests
Write Tests Using Shared Fixtures
Create Basic Custom Fixture
Create Advanced Custom Fixture
Use Parameters in Class-Based Tests
How to Write Parameterized Tests
How to Initialize Parameterization Properties
Specify Parameterization Level
Specify How Parameters Are Combined
Use External Parameters in Tests
Create Basic Parameterized Test
Create Advanced Parameterized Test
Use External Parameters in Parameterized Test
Define Parameters at Suite Creation Time
Create Simple Test Suites
Run Tests for Various Workflows
Set Up Example Tests
Run All Tests in Class or Function
Run Single Test in Class or Function
Run Test Suites by Name
Run Test Suites from Test Array
Run Tests with Customized Test Runner
Programmatically Access Test Diagnostics
Add Plugin to Test Runner
Write Plugins to Extend TestRunner
Custom Plugins Overview
Extending Test Session Level Plugin Methods
Extending Test Suite Level Plugin Methods
Extending Test Class Level Plugin Methods
Extending Test Level Plugin Methods
Create Custom Plugin
Run Tests in Parallel with Custom Plugin
Write Plugin to Add Data to Test Results
Write Plugin to Save Diagnostic Details
Plugin to Generate Custom Test Output Format
Analyze Test Case Results
Analyze Failed Test Results
Rerun Failed Tests
Dynamically Filtered Tests
Test Methods
Method Setup and Teardown Code
Class Setup and Teardown Code
Create Custom Constraint
Create Custom Boolean Constraint
Overview of App Testing Framework
App Testing
Gesture Support of UI Components
Write a Test for an App
Write Tests for an App
Write Tests That Use App Testing and Mocking Frameworks
Create App
Test App With Manual Intervention
Create Fully Automated Test
Overview of Performance Testing Framework
Determine Bounds of Measured Code
Types of Time Experiments
Write Performance Tests with Measurement Boundaries
Run Performance Tests
Understand Invalid Test Results
Test Performance Using Scripts or Functions
Test Performance Using Classes
Measure Fast Executing Test Code
Create Mock Object
Specify Mock Object Behavior
Define Mock Method Behavior
Define Mock Property Behavior
Define Repeating and Subsequent Behavior
Summary of Behaviors
Qualify Mock Object Interaction
Qualify Mock Method Interaction
Qualify Mock Property Interaction
Use Mock Object Constraints
Summary of Qualifications
Ways to Write Unit Tests
Script-Based Unit Tests
Function-Based Unit Tests
Class-Based Unit Tests
Extend Unit Testing Framework
Compile MATLAB Unit Tests
Run Tests with Standalone Applications
Run Tests in Parallel with Standalone Applications
TestRand Class Definition Summary
Generate Code Coverage Report in HTML Format
Statement Coverage for MATLAB Source Code
Function Coverage for MATLAB Source Code
Generate and Analyze HTML Coverage Report
QuadraticPolynomial Class Definition
Insert Test Code Using Editor
Create Test Class
Add Parameters and Methods
Run Tests in Test Class
Develop and Integrate Software with Continuous Integration
Continuous Integration Workflow
Continuous Integration with MathWorks Products
Generate Artifacts Using MATLAB Unit Test Plugins
Continuous Integration with MATLAB on CI Platforms
Azure DevOps
Bamboo
CircleCI
GitHub Actions
GitLab CI/CD
Jenkins
Travis CI
Other Platforms
Build Automation
Overview of MATLAB Build Tool
Create Plan with Tasks
Run Tasks in Plan
Create and Run Tasks Using Build Tool
Create Build File
Summary of Build File
Visualize Task Dependencies
Run Tasks in Plan
System object Usage and Authoring
What Are System Objects?
Running a System Object
System Object Functions
System Objects vs MATLAB Functions
System Objects vs. MATLAB Functions
Process Audio Data Using Only MATLAB Functions Code
Process Audio Data Using System Objects
System Design in MATLAB Using System Objects
System Design and Simulation in MATLAB
Create Individual Components
Configure Components
Create and Configure Components at the Same Time
Assemble Components Into System
Run Your System
Reconfiguring Objects
Define Basic System Objects
Create System Object Class
Define Algorithm
Change the Number of Inputs
Validate Property and Input Values
Validate a Single Property
Validate Interdependent Properties
Validate Inputs
Complete Class Example
Initialize Properties and Setup One-Time Calculations
Set Property Values at Construction Time
Reset Algorithm and Release Resources
Reset Algorithm State
Release System Object Resources
Define Property Attributes
Specify Property as Nontunable
Specify Property as DiscreteState
Example Class with Various Property Attributes
Hide Inactive Properties
Specify Inactive Property
Complete Class Definition File with Inactive Properties Method
Limit Property Values to Finite List
Property Validation with mustBeMember
Enumeration Property
Create a Whiteboard System Object
Process Tuned Properties
Define Composite System Objects
Define Finite Source Objects
Use the FiniteSource Class and Specify End of the Source
Complete Class Definition File with Finite Source
Save and Load System Object
Save System Object and Child Object
Load System Object and Child Object
Complete Class Definition Files with Save and Load
Define System Object Information
Handle Input Specification Changes
React to Input Specification Changes
Restrict Input Specification Changes
Summary of Call Sequence
Setup Call Sequence
Running the Object or Step Call Sequence
Reset Method Call Sequence
Release Method Call Sequence
Detailed Call Sequence
setup Call Sequence
Running the Object or step Call Sequence
reset Call Sequence
release Call Sequence
Tips for Defining System Objects
General
Inputs and Outputs
Using ~ as an Input Argument in Method Definitions
Properties
Text Comparisons
Simulink
Code Generation
Insert System Object Code Using MATLAB Editor
Define System Objects with Code Insertion
Create a Temperature Enumeration
Create Custom Property for Freezing Point
Add Method to Validate Inputs
Analyze System Object Code
Use Global Variables in System Objects
System Object Global Variables in MATLAB
System Object Global Variables in Simulink
Create Moving Average System Object
Create New System Objects for File Input and Output
Create Composite System Object

Polecaj historie