没有合适的资源?快使用搜索试试~ 我知道了~
matlab7编程教程
4星 · 超过85%的资源 需积分: 0 264 下载量 129 浏览量
2007-07-12
10:37:50
上传
评论
收藏 4.72MB PDF 举报
温馨提示
试读
668页
matlab都知道哈
资源推荐
资源详情
资源评论
Programming
Version 7
MATLAB
®
The Language of Technical Computing
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.
MATLAB Programming
COPYRIGHT 1984 - 2004 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.
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: June 2004 First printing New for MATLAB 7.0 (Release 14).
Formerly part of Using MATLAB.
i
Contents
1
Data Structures
Creating and Concatenating Matrices . . . . . . . . . . . . . . . . . . 1-3
Constructing a Simple Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4
Specialized Matrix Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4
Concatenating Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-7
Matrix Concatenation Functions . . . . . . . . . . . . . . . . . . . . . . . . 1-8
Generating a Numeric Sequence . . . . . . . . . . . . . . . . . . . . . . . 1-10
Combining Unlike Data Types . . . . . . . . . . . . . . . . . . . . . . . . . 1-11
Accessing Elements of a Matrix . . . . . . . . . . . . . . . . . . . . . . . 1-14
Accessing Single Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-14
Linear Indexing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-15
Functions That Control Indexing Style . . . . . . . . . . . . . . . . . . 1-16
Accessing Multiple Elements . . . . . . . . . . . . . . . . . . . . . . . . . . 1-16
Logical Indexing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-18
Getting Information About a Matrix . . . . . . . . . . . . . . . . . . . 1-19
Dimensions of the Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-19
Data Types Used in the Matrix . . . . . . . . . . . . . . . . . . . . . . . . 1-20
Data Structures Used in the Matrix . . . . . . . . . . . . . . . . . . . . 1-21
Resizing and Reshaping Matrices . . . . . . . . . . . . . . . . . . . . . 1-22
Expanding the Size of a Matrix . . . . . . . . . . . . . . . . . . . . . . . . 1-22
Diminishing the Size of a Matrix . . . . . . . . . . . . . . . . . . . . . . . 1-23
Reshaping a Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-24
Shifting and Sorting Matrices . . . . . . . . . . . . . . . . . . . . . . . . . 1-26
Shift and Sort Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-26
Shifting the Location of Matrix Elements . . . . . . . . . . . . . . . . 1-26
Sorting the Data in Each Column . . . . . . . . . . . . . . . . . . . . . . 1-28
Sorting the Data in Each Row . . . . . . . . . . . . . . . . . . . . . . . . . 1-28
Sorting Row Vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-29
ii Contents
Operating on Diagonal Matrices . . . . . . . . . . . . . . . . . . . . . . . 1-30
Constructing a Matrix from a Diagonal Vector . . . . . . . . . . . . 1-30
Returning a Triangular Portion of a Matrix . . . . . . . . . . . . . . . 1-31
Concatenating Matrices Diagonally . . . . . . . . . . . . . . . . . . . . . 1-31
Empty Matrices, Scalars, and Vectors . . . . . . . . . . . . . . . . . . 1-32
The Empty Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-32
Scalars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-33
Vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-34
Full and Sparse Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-35
Sparse Matrix Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-35
Multidimensional Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-37
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-37
Creating Multidimensional Arrays . . . . . . . . . . . . . . . . . . . . . . 1-39
Accessing Multidimensional Array Properties . . . . . . . . . . . . . 1-43
Indexing Multidimensional Arrays . . . . . . . . . . . . . . . . . . . . . . 1-43
Reshaping Multidimensional Arrays . . . . . . . . . . . . . . . . . . . . 1-47
Permuting Array Dimensions . . . . . . . . . . . . . . . . . . . . . . . . . . 1-49
Computing with Multidimensional Arrays . . . . . . . . . . . . . . . . 1-51
Organizing Data in Multidimensional Arrays . . . . . . . . . . . . . 1-53
Multidimensional Cell Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . 1-55
Multidimensional Structure Arrays . . . . . . . . . . . . . . . . . . . . . 1-56
Summary of Matrix and Array Functions . . . . . . . . . . . . . . . 1-58
2
Data Types
Overview of MATLAB Data Types . . . . . . . . . . . . . . . . . . . . . . 2-2
Numeric Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4
Integers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4
Floating-Point Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6
Complex Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-11
Infinity and NaN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-12
iii
Identifying Numeric Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-14
Display Format for Numeric Values . . . . . . . . . . . . . . . . . . . . . 2-14
Function Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-16
Logical Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-20
Creating a Logical Array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-20
How Logical Arrays Are Used . . . . . . . . . . . . . . . . . . . . . . . . . . 2-22
Identifying Logical Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-24
Characters and Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-25
Creating Character Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-25
Cell Arrays of Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-27
String Comparisons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-29
Searching and Replacing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-32
Converting from Numeric to String . . . . . . . . . . . . . . . . . . . . . 2-34
Converting from String to Numeric . . . . . . . . . . . . . . . . . . . . . 2-35
Function Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-37
Dates and Times . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-41
Types of Date Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-41
Conversions Between Date Formats . . . . . . . . . . . . . . . . . . . . . 2-43
Date String Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-44
Output Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-44
Current Date and Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-46
Function Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-47
Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-49
Building Structure Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-50
Accessing Data in Structure Arrays . . . . . . . . . . . . . . . . . . . . . 2-53
Using Dynamic Field Names . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-54
Finding the Size of Structure Arrays . . . . . . . . . . . . . . . . . . . . 2-55
Adding Fields to Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-56
Deleting Fields from Structures . . . . . . . . . . . . . . . . . . . . . . . . 2-56
Applying Functions and Operators . . . . . . . . . . . . . . . . . . . . . . 2-56
Writing Functions to Operate on Structures . . . . . . . . . . . . . . 2-57
Organizing Data in Structure Arrays . . . . . . . . . . . . . . . . . . . . 2-59
Nesting Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-63
Function Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-65
剩余667页未读,继续阅读
资源评论
- 无名tuzi2014-06-14不错,很实用
jizhqi
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功