没有合适的资源?快使用搜索试试~ 我知道了~
首页MATLAB编程指南:英文原版电子书解析
MATLAB编程指南:英文原版电子书解析
下载需积分: 10 | PDF格式 | 4.84MB |
更新于2024-07-29
| 175 浏览量 | 0 下载量 举报
"MATLAB7_Programming英文原版电子书.pdf"
MATLAB是MathWorks公司开发的一款强大的数学计算软件,广泛应用于工程计算、数据分析、算法开发、图形绘制等多个领域。"MATLAB7_Programming"这本书是针对MATLAB 7版本的编程指南,旨在帮助用户深入理解和熟练运用MATLAB进行技术计算。
MATLAB语言是该软件的核心部分,它是一种交互式的编程环境,结合了高级矩阵和数组处理、内置函数库以及图形用户界面设计等功能。在MATLAB 7版本中,用户可以期待更加强大和灵活的计算能力,包括更新的语法、更丰富的函数库以及优化的性能。
本书的内容可能涵盖了以下几个方面:
1. **基础操作**:介绍MATLAB的基本操作,如变量创建、数据类型(包括数值型、字符型、逻辑型等)、矩阵和数组的操作,以及基本的算术运算。
2. **控制结构**:包括循环(for、while)、条件语句(if-else)、函数定义等,这些都是编写复杂MATLAB程序的基础。
3. **函数和脚本**:讲解如何定义和使用MATLAB函数,以及编写脚本文件来组织代码。
4. **数据可视化**:MATLAB强大的图形功能,如2D和3D绘图,以及如何自定义图形属性以增强可视化效果。
5. **数值计算**:包括线性代数、微积分、统计分析、傅里叶变换等高级数学计算功能的使用。
6. **文件输入输出**:如何读写文本和二进制文件,以及与其他应用程序的数据交换。
7. **编程工具**:调试器、单元测试、性能分析工具等,用于提升代码质量和效率。
8. **高级话题**:如对象导向编程、并行计算、App Designer用于构建交互式应用等高级特性。
此外,书中可能还会介绍如何利用MATLAB与其他软件的接口,例如与C、C++、Java等语言的混合编程,以及如何通过MATLAB Compiler将MATLAB代码转换为可独立运行的应用程序。
为了获得技术支持,读者可以通过MathWorks公司的网站、在线新闻组、电子邮件服务、电话等多种方式联系。对于版权和使用条款,需要注意的是,尽管该电子书可以作为学习参考,但应遵循版权法规,仅限个人学习,不得用于商业目的。如果对MATLAB有进一步的需求,建议购买官方正版以获取完整支持和服务。
最后,"生物秀"是一个提供生物科学资源和讨论的平台,鼓励用户在这里分享资源、讨论问题,以提升个人在生物科学领域的技能和知识。如果你对MATLAB有任何疑问或需要更多的学习资源,可以访问这些平台寻求帮助。
![](https://csdnimg.cn/release/download_crawler_static/4100583/bg10.jpg)
xiv Contents
9
Scheduling Program Execution with Timers
Using a MATLAB Timer Object . . . . . . . . . . . . . . . . . . . . . . . . . 9-2
Example: Displaying a Message . . . . . . . . . . . . . . . . . . . . . . . . . 9-3
Creating Timer Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-4
Timer Object Naming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-5
Working with Timer Object Properties . . . . . . . . . . . . . . . . . . 9-6
Retrieving the Value of Timer Object Properties . . . . . . . . . . . . 9-6
Setting the Value of Timer Object Properties . . . . . . . . . . . . . . 9-7
Starting and Stopping Timers . . . . . . . . . . . . . . . . . . . . . . . . . . 9-9
Starting a Timer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-9
Starting a Timer at a Specified Time . . . . . . . . . . . . . . . . . . . . 9-10
Stopping Timer Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-10
Blocking the MATLAB Command Line . . . . . . . . . . . . . . . . . . 9-11
Creating and Executing Callback Functions . . . . . . . . . . . . 9-13
Associating Commands with Timer Object Events . . . . . . . . . 9-13
Creating Callback Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-14
Specifying the Value of Callback Function Properties . . . . . . 9-16
Timer Object Execution Modes . . . . . . . . . . . . . . . . . . . . . . . . 9-18
Executing a Timer Callback Function Once . . . . . . . . . . . . . . . 9-18
Executing a Timer Callback Function Multiple Times . . . . . . 9-19
Handling Callback Function Queuing Conflicts . . . . . . . . . . . 9-20
Deleting Timer Objects from Memory . . . . . . . . . . . . . . . . . . 9-22
Testing the Validity of a Timer Object . . . . . . . . . . . . . . . . . . . 9-22
Deleting All Existing Timer Objects . . . . . . . . . . . . . . . . . . . . . 9-22
Finding All Timer Objects in Memory . . . . . . . . . . . . . . . . . . 9-23
Finding Invisible Timer Objects . . . . . . . . . . . . . . . . . . . . . . . . 9-23
![](https://csdnimg.cn/release/download_crawler_static/4100583/bg11.jpg)
xv
10
Improving Performance and Memory Usage
Analyzing Your Program’s Performance . . . . . . . . . . . . . . . 10-2
The M-File Profiler Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-2
Stopwatch Timer Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-2
Techniques for Improving Performance . . . . . . . . . . . . . . . . 10-4
Vectorizing Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-4
Preallocating Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-7
Coding Loops in a MEX-File . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-9
Assigning to Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-9
Operating on Real Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-10
Using Appropriate Logical Operators . . . . . . . . . . . . . . . . . . . 10-10
Overloading Built-In Functions . . . . . . . . . . . . . . . . . . . . . . . 10-11
Functions Are Generally Faster Than Scripts . . . . . . . . . . . . 10-11
Load and Save Are Faster Than File I/O Functions . . . . . . . 10-11
Avoid Large Background Processes . . . . . . . . . . . . . . . . . . . . 10-11
Making Efficient Use of Memory . . . . . . . . . . . . . . . . . . . . . . 10-12
Memory Management Functions . . . . . . . . . . . . . . . . . . . . . . 10-12
Preallocating Arrays to Reduce Fragmentation . . . . . . . . . . . 10-13
Enlarging Arrays with repmat . . . . . . . . . . . . . . . . . . . . . . . . 10-13
Working with Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-13
Converting Full Matrices into Sparse . . . . . . . . . . . . . . . . . . . 10-15
Structure of Arrays vs. Array of Structures . . . . . . . . . . . . . . 10-15
Working with Large Amounts of Data . . . . . . . . . . . . . . . . . . 10-15
Resolving “Out of Memory” Errors . . . . . . . . . . . . . . . . . . . . 10-16
General Suggestions For Reclaiming Memory . . . . . . . . . . . . 10-16
Compressing Data in Memory . . . . . . . . . . . . . . . . . . . . . . . . . 10-16
Increasing System Swap Space . . . . . . . . . . . . . . . . . . . . . . . . 10-17
Freeing Up System Resources on Windows Systems . . . . . . . 10-18
Reloading Variables on UNIX Systems . . . . . . . . . . . . . . . . . 10-18
![](https://csdnimg.cn/release/download_crawler_static/4100583/bg12.jpg)
xvi Contents
11
Programming Tips
Command and Function Syntax . . . . . . . . . . . . . . . . . . . . . . . 11-3
Syntax Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-3
Command and Function Syntaxes . . . . . . . . . . . . . . . . . . . . . . 11-3
Command Line Continuation . . . . . . . . . . . . . . . . . . . . . . . . . . 11-3
Completing Commands Using the Tab Key . . . . . . . . . . . . . . . 11-4
Recalling Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-4
Clearing Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-5
Suppressing Output to the Screen . . . . . . . . . . . . . . . . . . . . . . 11-5
Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-6
Using the Help Browser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-6
Help on Functions from the Help Browser . . . . . . . . . . . . . . . . 11-7
Help on Functions from the Command Window . . . . . . . . . . . 11-7
Topical Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-7
Paged Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-8
Writing Your Own Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-8
Help for Subfunctions and Private Functions . . . . . . . . . . . . . 11-9
Help for Methods and Overloaded Functions . . . . . . . . . . . . . . 11-9
Development Environment . . . . . . . . . . . . . . . . . . . . . . . . . . 11-10
Workspace Browser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-10
Using the Find and Replace Utility . . . . . . . . . . . . . . . . . . . . 11-10
Commenting Out a Block of Code . . . . . . . . . . . . . . . . . . . . . . 11-11
Creating M-Files from Command History . . . . . . . . . . . . . . . 11-11
Editing M-Files in EMACS . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-11
M-File Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-12
M-File Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-12
Using Lowercase for Function Names . . . . . . . . . . . . . . . . . . 11-12
Getting a Function’s Name and Path . . . . . . . . . . . . . . . . . . . 11-13
What M-Files Does a Function Use? . . . . . . . . . . . . . . . . . . . . 11-13
Dependent Functions, Built-Ins, Classes . . . . . . . . . . . . . . . . 11-13
Function Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-14
Getting the Input and Output Arguments . . . . . . . . . . . . . . . 11-14
Variable Numbers of Arguments . . . . . . . . . . . . . . . . . . . . . . 11-14
String or Numeric Arguments . . . . . . . . . . . . . . . . . . . . . . . . . 11-15
![](https://csdnimg.cn/release/download_crawler_static/4100583/bg13.jpg)
xvii
Passing Arguments in a Structure . . . . . . . . . . . . . . . . . . . . . 11-15
Passing Arguments in a Cell Array . . . . . . . . . . . . . . . . . . . . 11-15
Program Development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-16
Planning the Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-16
Using Pseudo-Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-16
Selecting the Right Data Structures . . . . . . . . . . . . . . . . . . . . 11-16
General Coding Practices . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-17
Naming a Function Uniquely . . . . . . . . . . . . . . . . . . . . . . . . . 11-17
The Importance of Comments . . . . . . . . . . . . . . . . . . . . . . . . . 11-17
Coding in Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-18
Making Modifications in Steps . . . . . . . . . . . . . . . . . . . . . . . . 11-18
Functions with One Calling Function . . . . . . . . . . . . . . . . . . . 11-18
Testing the Final Program . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-18
Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-19
The MATLAB Debug Functions . . . . . . . . . . . . . . . . . . . . . . . 11-19
More Debug Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-19
The MATLAB Graphical Debugger . . . . . . . . . . . . . . . . . . . . . 11-20
A Quick Way to Examine Variables . . . . . . . . . . . . . . . . . . . . 11-20
Setting Breakpoints from the Command Line . . . . . . . . . . . . 11-21
Finding Line Numbers to Set Breakpoints . . . . . . . . . . . . . . . 11-21
Stopping Execution on an Error or Warning . . . . . . . . . . . . . 11-21
Locating an Error from the Error Message . . . . . . . . . . . . . . 11-21
Using Warnings to Help Debug . . . . . . . . . . . . . . . . . . . . . . . . 11-22
Making Code Execution Visible . . . . . . . . . . . . . . . . . . . . . . . 11-22
Debugging Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-22
Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-23
Rules for Variable Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-23
Making Sure Variable Names Are Valid . . . . . . . . . . . . . . . . 11-23
Don’t Use Function Names for Variables . . . . . . . . . . . . . . . . 11-24
Checking for Reserved Keywords . . . . . . . . . . . . . . . . . . . . . . 11-24
Avoid Using i and j for Variables . . . . . . . . . . . . . . . . . . . . . . 11-24
Avoid Overwriting Variables in Scripts . . . . . . . . . . . . . . . . . 11-25
Persistent Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-25
Protecting Persistent Variables . . . . . . . . . . . . . . . . . . . . . . . 11-25
Global Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-26
![](https://csdnimg.cn/release/download_crawler_static/4100583/bg14.jpg)
xviii Contents
Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-27
Creating Strings with Concatenation . . . . . . . . . . . . . . . . . . . 11-27
Comparing Methods of Concatenation . . . . . . . . . . . . . . . . . . 11-27
Store Arrays of Strings in a Cell Array . . . . . . . . . . . . . . . . . 11-28
Converting Between Strings and Cell Arrays . . . . . . . . . . . . 11-28
Search and Replace Using Regular Expressions . . . . . . . . . . 11-29
Evaluating Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-30
Find Alternatives to Using eval . . . . . . . . . . . . . . . . . . . . . . . 11-30
Assigning to a Series of Variables . . . . . . . . . . . . . . . . . . . . . . 11-30
Short-Circuit Logical Operators . . . . . . . . . . . . . . . . . . . . . . . 11-31
Changing the Counter Variable within a for Loop . . . . . . . . . 11-31
MATLAB Path . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-32
Precedence Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-32
File Precedence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-33
Adding a Directory to the Search Path . . . . . . . . . . . . . . . . . . 11-33
Handles to Functions Not on the Path . . . . . . . . . . . . . . . . . . 11-33
Making Toolbox File Changes Visible to MATLAB . . . . . . . . 11-34
Making Nontoolbox File Changes Visible to MATLAB . . . . . 11-35
Change Notification on Windows . . . . . . . . . . . . . . . . . . . . . . 11-35
Program Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-36
Using break, continue, and return . . . . . . . . . . . . . . . . . . . . . 11-36
Using switch Versus if . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-37
MATLAB case Evaluates Strings . . . . . . . . . . . . . . . . . . . . . . 11-37
Multiple Conditions in a case Statement . . . . . . . . . . . . . . . . 11-37
Implicit Break in switch-case . . . . . . . . . . . . . . . . . . . . . . . . . 11-38
Variable Scope in a switch . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-38
Catching Errors with try-catch . . . . . . . . . . . . . . . . . . . . . . . . 11-38
Nested try-catch Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-39
Forcing an Early Return from a Function . . . . . . . . . . . . . . . 11-39
Save and Load . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-40
Saving Data from the Workspace . . . . . . . . . . . . . . . . . . . . . . 11-40
Loading Data into the Workspace . . . . . . . . . . . . . . . . . . . . . . 11-40
Viewing Variables in a MAT-File . . . . . . . . . . . . . . . . . . . . . . 11-41
Appending to a MAT-File . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-41
Save and Load on Startup or Quit . . . . . . . . . . . . . . . . . . . . . 11-42
Saving to an ASCII File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-42
剩余668页未读,继续阅读
相关推荐
![](https://profile-avatar.csdnimg.cn/03db891aa3af4817a16694393ac2b7dd_joyjiyuan.jpg!1)
joyjiyuan
- 粉丝: 592
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![](https://csdnimg.cn/release/wenkucmsfe/public/img/voice.245cc511.png)
最新资源
- 开放平台客户端软件操作方法及装置技术解析
- 深入探讨HTML编程与压缩技术应用
- VC++6.0实现txt数据文件读写与格式转换教程
- Rx-Mvp框架在Android开发中的实践应用
- Flutter中实现ETL图表的diagram_editor包应用解析
- 易语言实现高级文件操作技术详解
- APKTOOL 2.0.0RC3:安卓4.4兼容的全自动APK反编译签名工具
- CSDN技术主题月深度学习讲师PPT精选
- Lireddit: TypeScript项目开发探索
- 建筑物被动式通风新进展:可转动装置的创新设计
- 奥尼ANC狼魔摄像头驱动程序官方v5.8.54300版下载
- LL(1)和SLR(1)语法分析算法的设计与实现
- 精选27款文艺小清新毕业设计PPT模板
- HPL 2.3版本的高性能计算资源包解析
- 光立方编程指南:实用代码参考
- 探索Python库在数据分析中的应用:pandas-gbq-0.19.2介绍
安全验证
文档复制为VIP权益,开通VIP直接复制
![](https://csdnimg.cn/release/wenkucmsfe/public/img/green-success.6a4acb44.png)