首页 第2章 数组和矩阵

第2章 数组和矩阵

举报
开通vip

第2章 数组和矩阵第2章 数组和矩阵 第二章 数组和矩阵 第二章 数组和矩阵 第二章 数组和矩阵 向量(矩阵)和数组是有区别的 向量(矩阵)是一个数学概念,数组是一个计算机名词,一组数而已。非要给数组赋予数 学含义,则一维数组相当于向量,二维数组相当于矩阵,向量或矩阵是数组的子集。 向量(矩阵)的四则运算有具体的数学定义,使用通常的四则运算符号。数组运算特指数 组对应元素之间的运算(也称点运算),其运算符是在通常的运算符符前加一点作为其运算符。 二者在加、减与数乘三种运算上恰好一致: 数组加减:A+B与A-B;矩阵加减:A...

第2章 数组和矩阵
第2章 数组和矩阵 第二章 数组和矩阵 第二章 数组和矩阵 第二章 数组和矩阵 向量(矩阵)和数组是有区别的 向量(矩阵)是一个数学概念,数组是一个计算机名词,一组数而已。非要给数组赋予数 学含义,则一维数组相当于向量,二维数组相当于矩阵,向量或矩阵是数组的子集。 向量(矩阵)的四则运算有具体的数学定义,使用通常的四则运算符号。数组运算特指数 组对应元素之间的运算(也称点运算),其运算符是在通常的运算符符前加一点作为其运算符。 二者在加、减与数乘三种运算上恰好一致: 数组加减:A+B与A-B;矩阵加减:A+B与A-B,都是对应元素之间加减(不分?与.?) 数乘数组:k.*A或A.*k;数乘矩阵:k*A或A*k,都是k乘A的每个元素 但注意以下两点: (1)向量(矩阵)的乘法、乘方和除法等运算按线性变换定义,与数组对应的运算不一样。 (2)数与矩阵加减、矩阵除法在数学没有定义,MATLAB中为简便起见定义了这两类运算; 数组运算: 数与数组加减: k+A与k-A ,k加(减)A的每个元素 数组乘数组: A.*B,对应元素相乘 数组乘方: A.^k A的每个元素k次方, k.^A 分别以k底A的元素为指数求幂值 数除以数组: k./A和A.\k k分别被A的元素除 数组除法: 左除A.\B右除B./A,对应元素相除 矩阵运算: 数与矩阵加减:k+A与k-A,等价于k*ones(size(A))+-A %特殊的定义 矩阵乘法:A*B,按数学定义的矩阵乘法规则 矩阵乘方:A^k,k个矩阵A相乘 矩阵除法:左除A\B 右除B/A,分别为AX=B和XA=B的解 搞清楚这些区别,发现数组的运算其实很简单,值得注意的是,在实际计算中什么时候 需要对变量进行数组运算,什么时候需要对变量进行向量(矩阵)运算。 比如第一章的积分表达式中的变量x就只能做数组元素。 在不考虑数学意义时数组与向量(矩阵)是一回事~ 以下只讨论向量(矩阵)的运算 layout development cities in developed countries show that developing rail transit Guide and an important means of achieving sustainable urban development. More than the bulk of the urban rail transit vehicles, rail traffic in the urban space layout and guide the evacuation, optimizing the structure and other aspects also play an important role in its role as the scale becomes more important. Rail transit on land development and stimulation is achieved through its good accessibility, under the dual role of mechanisms in land and planning, transport accessibility high land along the rail transit development and high strength, promotion of urban morphology and land use patterns to adjust accordingly. 1, and Copenhagen 1947, Copenhagen refers to shaped planning introduced, requirements land development along narrow of finger corridor concentrated, refers to shaped planning guide big Copenhagen area along track traffic line clear defined of corridor for Metro development, through track traffic and city development of integration, will along development concentrated in track station around a km around, around track site land implementation integrated intensive development, and provides good of non-mobile of way received connection facilities, Ensure that a larger proportion of the region's residents commute using mass transit. Figure 5.1-3 Copenhagen Metro City Development 2, Tokyo 5.1-4 Tokyo Metro to guide regional development (left: 1950, right: 2000) formation is the mass transit system of the city of Tokyo, which have been developed under the guidance of. Eastern suburbs ... Established to track traffic based on the network-city, using rail-oriented intensive development mode has been recognized in many cities. Created the urban structure of the node, forming the urban rail transit-dependent and lifestyle, as well as mass transit systems provide adequate passenger protection. 5.1.3 to guide the healthy development of MATLAB提供的数据类型(如下图),有十余种之多。但所有的MATLAB变量,不管它是什么类型的,都以数组或矩阵的形式保存。矩阵是数组的二维版本。 MATLAB的数据类型 ARRAY 函数句柄 logical char numeric cell structure Java类 整型 single double int8,uint8 int16,uint 16 int32,uint 32 说明:int8表示一个字节(8bit) 2.1 表达式 2.1 表达式 2.1 表达式 与其他程序语言类似,MATLAB提供了数学表达式功能。但是,与大多数程序语言不同的是,这些表达式主要针对矩阵进行操作。与表达式相关的 内容 财务内部控制制度的内容财务内部控制制度的内容人员招聘与配置的内容项目成本控制的内容消防安全演练内容 主要包括变量、数值(常数)、运算符和函数等。 2.1.1 变量 2.1.1 变量 2.1.1 变量 1?MATLAB变量使用前不需要任何类型声明和维数说明。 2?命名规则同C语言,变量名最长63个字符(7.0版) 3?变量严格区分大小写 2.1.2数值表示 2.1.2数值表示 2.1.2数值表示 MATLAB使用传统的数值表示方法。对于比较长的数,使用科学计数法,用字母e指定以10为底的幂次。虚数用i或j作为后缀。 所有数值在内部保存为IEEE浮点标准指定的long型格式。其精度为16layout development cities in developed countries show that developing rail transit Guide and an important means of achieving sustainable urban development. More than the bulk of the urban rail transit vehicles, rail traffic in the urban space layout and guide the evacuation, optimizing the structure and other aspects also play an important role in its role as the scale becomes more important. Rail transit on land development and stimulation is achieved through its good accessibility, under the dual role of mechanisms in land and planning, transport accessibility high land along the rail transit development and high strength, promotion of urban morphology and land use patterns to adjust accordingly. 1, and Copenhagen 1947, Copenhagen refers to shaped planning introduced, requirements land development along narrow of finger corridor concentrated, refers to shaped planning guide big Copenhagen area along track traffic line clear defined of corridor for Metro development, through track traffic and city development of integration, will along development concentrated in track station around a km around, around track site land implementation integrated intensive development, and provides good of non-mobile of way received connection facilities, Ensure that a larger proportion of the region's residents commute using mass transit. Figure 5.1-3 Copenhagen Metro City Development 2, Tokyo 5.1-4 Tokyo Metro to guide regional development (left: 1950, right: 2000) formation is the mass transit system of the city of Tokyo, which have been developed under the guidance of. Eastern suburbs ... Established to track traffic based on the network-city, using rail-oriented intensive development mode has been recognized in many cities. Created the urban structure of the node, forming the urban rail transit-dependent and lifestyle, as well as mass transit systems provide adequate passenger protection. 5.1.3 to guide the healthy development of -308+308个小数位,范围大约为10~10。 内置常数:pi,i,j,eps,realmax,realmin,inf,NaN 2.1.3 运算符 2.1.3 运算符 2.1.3 运算符 表达式采用的算术运算符和优光规则按此顺序: + (加)、_ (减)、* (乘)、/ (除)、\ (左除)、^ (幂)、’ (复数共轭转置)、()(优先) 2.1.4 函数 2.1.4 函数 2.1.4 函数 使用help 函数名获得函数帮助 2(2构造数组 2(2构造数组 2(2构造数组 1、直接构造:用空格或逗号间隔数组元素,然后用方括号括起来: x=[1,2,3,4,5,6] 2、增量法构造:使用冒号操作符创建数组。 a= first:end。%递增、且步长为1的数组 a=first:step:end。%指定增量步长值创建任何等差序列(数组) 3、用linspace 函数构造 x=linspace(first,last,num) %需要指定首尾值和元素总个数,步长根据 num 平均分配 2.3 构造矩阵 2.3 构造矩阵 2.3 构造矩阵 MAITLAB中,二维数组称为矩阵。图形图像方面要涉及到大量的矩阵运算,比如,一幅数字图像就是—个矩阵,矩阵中的每个元素表示图像上每个像素的信息。那么针对图像所作的任何操作实质上都是针对矩阵进行的。 2.3.1 简单的创建方法 2.3.1 简单的创建方法 2.3.1 简单的创建方法 使用矩阵创建符号[ ],用逗号或空格隔开各元素间;用分号隔开各行。必须注意各行必须具有相同的元素个数 layout development cities in developed countries show that developing rail transit Guide and an important means of achieving sustainable urban development. More than the bulk of the urban rail transit vehicles, rail traffic in the urban space layout and guide the evacuation, optimizing the structure and other aspects also play an important role in its role as the scale becomes more important. Rail transit on land development and stimulation is achieved through its good accessibility, under the dual role of mechanisms in land and planning, transport accessibility high land along the rail transit development and high strength, promotion of urban morphology and land use patterns to adjust accordingly. 1, and Copenhagen 1947, Copenhagen refers to shaped planning introduced, requirements land development along narrow of finger corridor concentrated, refers to shaped planning guide big Copenhagen area along track traffic line clear defined of corridor for Metro development, through track traffic and city development of integration, will along development concentrated in track station around a km around, around track site land implementation integrated intensive development, and provides good of non-mobile of way received connection facilities, Ensure that a larger proportion of the region's residents commute using mass transit. Figure 5.1-3 Copenhagen Metro City Development 2, Tokyo 5.1-4 Tokyo Metro to guide regional development (left: 1950, right: 2000) formation is the mass transit system of the city of Tokyo, which have been developed under the guidance of. Eastern suburbs ... Established to track traffic based on the network-city, using rail-oriented intensive development mode has been recognized in many cities. Created the urban structure of the node, forming the urban rail transit-dependent and lifestyle, as well as mass transit systems provide adequate passenger protection. 5.1.3 to guide the healthy development of 2.3.2 构造特殊矩阵 2.3.2 构造特殊矩阵 2.3.2 构造特殊矩阵 函数 功能 ones 创建一个所有元素都为1的矩阵 zeros 创建一个所有元素都为0的矩阵 eye 创建一个对角线元素为1,其他元素为0 的矩阵 diag 根据向量创建对角矩阵 magic 创建一个方阵,所有行、列、对角线上的元素的和相等 rand 创建一个矩阵或数组,其中的元素为服从均匀分布的随机数 randn 创建一个矩阵或数组,其中的元素为服从正态分布的随机数 randpem 创建一个向量(1×n的矩阵) 注:表中的大部分函数返回double型的矩阵。但是,可以用ones,zeros 和eye函数生成任何数值类型的基本数组。方法是将数据类型名作为函数的最后 一个参数值(class()函数可检测数据类型): A=zeros(4,6);class(A) %class()返回矩阵A数据类型为 double A=zeros(4,6,'uint32') ;class (A) %显示的数据类型为uint32的矩阵 函数示例: A=magic(5) % 5阶魔方阵,每行、列和主对角线上的和相等。 A=rand(5)*20 %服从均匀分布的随机数的矩阵或数组,每个元素乘以20 A=[10,9,8,-7,5]; B=diag(A,-1) %以A为对角线的对角矩阵,-1表示元素放在主对角线下方 2.3.3 聚合矩阵 2.3.3 聚合矩阵 2.3.3 聚合矩阵 矩阵聚合是通过连接一个或多个矩阵来形成一个新的矩阵。 1、使用符号[ ] 聚合:表达式c=[A B]水平聚合,c=[A;B]垂向聚合。 A=ones(3,5)*6; %3×5的矩阵,元素为6 B=rand(3,5); %3×5的矩阵,元素为随机数 layout development cities in developed countries show that developing rail transit Guide and an important means of achieving sustainable urban development. More than the bulk of the urban rail transit vehicles, rail traffic in the urban space layout and guide the evacuation, optimizing the structure and other aspects also play an important role in its role as the scale becomes more important. Rail transit on land development and stimulation is achieved through its good accessibility, under the dual role of mechanisms in land and planning, transport accessibility high land along the rail transit development and high strength, promotion of urban morphology and land use patterns to adjust accordingly. 1, and Copenhagen 1947, Copenhagen refers to shaped planning introduced, requirements land development along narrow of finger corridor concentrated, refers to shaped planning guide big Copenhagen area along track traffic line clear defined of corridor for Metro development, through track traffic and city development of integration, will along development concentrated in track station around a km around, around track site land implementation integrated intensive development, and provides good of non-mobile of way received connection facilities, Ensure that a larger proportion of the region's residents commute using mass transit. Figure 5.1-3 Copenhagen Metro City Development 2, Tokyo 5.1-4 Tokyo Metro to guide regional development (left: 1950, right: 2000) formation is the mass transit system of the city of Tokyo, which have been developed under the guidance of. Eastern suburbs ... Established to track traffic based on the network-city, using rail-oriented intensive development mode has been recognized in many cities. Created the urban structure of the node, forming the urban rail transit-dependent and lifestyle, as well as mass transit systems provide adequate passenger protection. 5.1.3 to guide the healthy development of D=[A B] %横向(列)聚合A和B, 要求 对教师党员的评价套管和固井爆破片与爆破装置仓库管理基本要求三甲医院都需要复审吗 A,B行数相同 C=[A;B] %垂向(行)聚合A和B,要求A,B列数相同 2、使用函数聚合 函数 描述 cat 沿指定的维聚合矩阵 horzcat 水平聚合矩阵 vertcat 垂向聚合矩阵 repmat 通过复制与蝶置来创建新矩阵 blkdiag 用已有矩阵创建块对角矩阵 函数示例:(使用cat和vertcat函数可以代替[]实现矩阵的聚合) A=magic(3);B=[-5 -6 -9;-4 -4 -2;1 2 3 ]; cat1ab=cat(1,A,B) % 行(垂向)聚合,等价于[A;B] cat2ab=cat(2,A,B) % 列(横向)聚合,等价于[A B] vab=vertcat(A,B) % 行聚合,等价于[A;B] M=[1 2;3 4]; repM=Repmat(M,2,3) %将 M 视为一个元素的m×n矩阵。 C=eye(2)*8; blkdgabc=blkdiag(A,B,C) % 以A,B,C为块的对角矩阵 2.3.4 聚合不同类型的矩阵 2.3.4 聚合不同类型的矩阵 2.3.4 聚合不同类型的矩阵 聚合矩阵时,若矩阵的数据类型不同,则MATLAB会自动进行类型转换。 高精度矩阵和低精度矩阵构造新矩阵时,新矩阵是低精度型的 (1)single型和double型矩阵聚合为single型。 X=[single(4.5) pi 5.73*10^300] %这也是聚合,3个1×1矩阵的聚合。 x=[ones(2)*2 ones(2,3,'single') ];class(x)%两矩阵聚合为single型。 layout development cities in developed countries show that developing rail transit Guide and an important means of achieving sustainable urban development. More than the bulk of the urban rail transit vehicles, rail traffic in the urban space layout and guide the evacuation, optimizing the structure and other aspects also play an important role in its role as the scale becomes more important. Rail transit on land development and stimulation is achieved through its good accessibility, under the dual role of mechanisms in land and planning, transport accessibility high land along the rail transit development and high strength, promotion of urban morphology and land use patterns to adjust accordingly. 1, and Copenhagen 1947, Copenhagen refers to shaped planning introduced, requirements land development along narrow of finger corridor concentrated, refers to shaped planning guide big Copenhagen area along track traffic line clear defined of corridor for Metro development, through track traffic and city development of integration, will along development concentrated in track station around a km around, around track site land implementation integrated intensive development, and provides good of non-mobile of way received connection facilities, Ensure that a larger proportion of the region's residents commute using mass transit. Figure 5.1-3 Copenhagen Metro City Development 2, Tokyo 5.1-4 Tokyo Metro to guide regional development (left: 1950, right: 2000) formation is the mass transit system of the city of Tokyo, which have been developed under the guidance of. Eastern suburbs ... Established to track traffic based on the network-city, using rail-oriented intensive development mode has been recognized in many cities. Created the urban structure of the node, forming the urban rail transit-dependent and lifestyle, as well as mass transit systems provide adequate passenger protection. 5.1.3 to guide the healthy development of (2)character和double型矩阵聚合为character型: x=[‘A’ ‘B’ ‘C’ 68 69 70] %x=ABCDEF;class(x)=char (3)logical和double型矩阵聚合为double,比较特殊: x=[true false false pi sqrt(7)] % x=1.0000 0 0 3.1416 2.6458;class(x)=double 2.4 获取矩阵的元素 2.4 获取矩阵的元素 2.4 获取矩阵的元素 2.4.1获取单个元素 2.4.1获取单个元素 2.4.1获取单个元素 A(row,column) %返回矩阵中第row行,第column列元素 A(m) %返回矩阵中的第m元素。 注:A(m)形式按矩阵的存贮顺序访问。即行优先(行标变化最快)原则,比 如一个三阶方阵的存贮顺序是a,a,a,a,a,a,a,a,a。显然A(4)=a。 11213121222331323321一般对一个 m×n矩阵A(i,j)和A(p)的对应关系为:p=(j-1)* m+i。 函数sub2ind()和ind2sub()可以完成单索引p和位置(i,j)间的转换。 A=[1 2 3 ;4 5 6 ;7 8 9] p=sub2ind(size(A),2,3) %size(A)返回矩阵A的行列值,A(2,3)为A(8)。 [row,col]=ind2sub(size(A),8) %返回A(8)的下标(2,3)。 2.4.2 获取多个元素 2.4.2 获取多个元素 2.4.2 获取多个元素 仔细体会冒号:,end关键字及first:step:end格式的使用。 A=magic(4) S=A(1,4) + A(2,4) + A(3,4) + A(4,4) %求第4列1~4行元素的和 S=sum(A(1:4,4)) %同上,求第4列1~4行元素的和 S=sum(A(:,2)) %求第2列所有元素的和 A(1:3:16)=-10 %每隔两个元素处的值改为-10,注意按存贮顺序访问 A(1:3,end)=10 %将矩阵A的1,3行中最后一个元素的值替换为10。 layout development cities in developed countries show that developing rail transit Guide and an important means of achieving sustainable urban development. More than the bulk of the urban rail transit vehicles, rail traffic in the urban space layout and guide the evacuation, optimizing the structure and other aspects also play an important role in its role as the scale becomes more important. Rail transit on land development and stimulation is achieved through its good accessibility, under the dual role of mechanisms in land and planning, transport accessibility high land along the rail transit development and high strength, promotion of urban morphology and land use patterns to adjust accordingly. 1, and Copenhagen 1947, Copenhagen refers to shaped planning introduced, requirements land development along narrow of finger corridor concentrated, refers to shaped planning guide big Copenhagen area along track traffic line clear defined of corridor for Metro development, through track traffic and city development of integration, will along development concentrated in track station around a km around, around track site land implementation integrated intensive development, and provides good of non-mobile of way received connection facilities, Ensure that a larger proportion of the region's residents commute using mass transit. Figure 5.1-3 Copenhagen Metro City Development 2, Tokyo 5.1-4 Tokyo Metro to guide regional development (left: 1950, right: 2000) formation is the mass transit system of the city of Tokyo, which have been developed under the guidance of. Eastern suburbs ... Established to track traffic based on the network-city, using rail-oriented intensive development mode has been recognized in many cities. Created the urban structure of the node, forming the urban rail transit-dependent and lifestyle, as well as mass transit systems provide adequate passenger protection. 5.1.3 to guide the healthy development of A(:) %按存贮顺序操作A的所有元素,此处为显示。 2.5 获取与矩阵有关的信息 2.5 获取与矩阵有关的信息 2.5 获取与矩阵有关的信息 矩阵信息函数 函数 功能 Length 返回矩阵最长维的长度 ndims 返回矩阵维数 numel 返回矩阵元素的个数 size 返回每一维的长度 下面这个例子演示上表中部分函数的使用。 A=rand(5)*10; A(4:5,:)=[] %第四行,第五行各列元素全部被删除 sum(A(:))/numel(A) %计算矩阵A中所有元素求和后再算均值。 % 查找矩阵中大小介于5 和7 之间的所有元素。 if ndims(A)~=2 % ~=不等于,如果A的维数不是2 即不是矩阵,就结束程序。 return end [rows,cols]=size(A); for m=1:rows %行作为外循环是符合存贮顺序的,是高效率的。 for n=1:cols if A(m,n)>=5 && A(m,n)<=7 % &&逻辑与运算符 disp(sprintf('A(%d,%d)=%5.2f',n,m,A(m,n)));%和C相同的的输出语句sprintf end end end 下表中的函数检查矩阵中的元素是否属于指定的数据类型: 数据类型检查函数 函数 功能 isa 是否属于给定类型(可代替以下各函数) iscell 确定输入数据是否属于单元(元胞)数组 iscellstr 确定输入数据是否属于字符串元胞数组 ischar 确定输入数据是否属于字符数组 isfloat 确定输入数据是否属于浮点数组 isinteger 确定输入数据是否属于整型数组 layout development cities in developed countries show that developing rail transit Guide and an important means of achieving sustainable urban development. More than the bulk of the urban rail transit vehicles, rail traffic in the urban space layout and guide the evacuation, optimizing the structure and other aspects also play an important role in its role as the scale becomes more important. Rail transit on land development and stimulation is achieved through its good accessibility, under the dual role of mechanisms in land and planning, transport accessibility high land along the rail transit development and high strength, promotion of urban morphology and land use patterns to adjust accordingly. 1, and Copenhagen 1947, Copenhagen refers to shaped planning introduced, requirements land development along narrow of finger corridor concentrated, refers to shaped planning guide big Copenhagen area along track traffic line clear defined of corridor for Metro development, through track traffic and city development of integration, will along development concentrated in track station around a km around, around track site land implementation integrated intensive development, and provides good of non-mobile of way received connection facilities, Ensure that a larger proportion of the region's residents commute using mass transit. Figure 5.1-3 Copenhagen Metro City Development 2, Tokyo 5.1-4 Tokyo Metro to guide regional development (left: 1950, right: 2000) formation is the mass transit system of the city of Tokyo, which have been developed under the guidance of. Eastern suburbs ... Established to track traffic based on the network-city, using rail-oriented intensive development mode has been recognized in many cities. Created the urban structure of the node, forming the urban rail transit-dependent and lifestyle, as well as mass transit systems provide adequate passenger protection. 5.1.3 to guide the healthy development of islogical 确定输入数据是否属于逻辑数组 isnumeric 确定输入数据是否属于数值数组 isreal 确定输入数据是否属于实型值数组 isstruct 确定输入数据是否属于结构数组 下面的代码从向量中找出数组中的实数。 A=[5+7i 6/7 4.23 39j pi 9-2i]; for m=1:numel(A) if isnumeric(A(m))&&isreal(A(m)) %matlab中logical也是用数值的,这条件不多余 disp(A(m)) end end 判断数组A是否为字符串数组 A=['This ' 'is ' 'character'] ischar(A) isa(A,'char') %与ischar()函数效果相同 下表中的函数检查矩阵中的元素是否为指定数据结构。 数据结构检查函数 函数 功能 Isempty 确定输入数据是否为空 Isscalar 确定输入数据是否为标量 Isspace 确定输入数据是否为稀疏矩阵 Isvector 确定输入数据是否为向量 2.6 缩放和重塑矩阵2.6 缩放和重塑矩阵2.6 缩放和重塑矩阵 2.6.1 缩放矩阵2.6.1 缩放矩阵2.6.1 缩放矩阵 使用 A(i,j)=p的形式对矩阵A(m×n)的元素赋值,若i,j 超出了m,n.。矩阵 会自动放大。但使用A(m)=p形式,m超出矩阵范围,则发生错误。 A=magic(4) A(17)=3 %错误,单索引方式不能缩放矩阵 A(1,5)=3 %将A放大为 4×5矩阵,放大后未赋值的元素置零 使使用 A(i,j)=[]的形式,可以删除矩阵中的行和列,但不能删除单个元素。 layout development cities in developed countries show that developing rail transit Guide and an important means of achieving sustainable urban development. More than the bulk of the urban rail transit vehicles, rail traffic in the urban space layout and guide the evacuation, optimizing the structure and other aspects also play an important role in its role as the scale becomes more important. Rail transit on land development and stimulation is achieved through its good accessibility, under the dual role of mechanisms in land and planning, transport accessibility high land along the rail transit development and high strength, promotion of urban morphology and land use patterns to adjust accordingly. 1, and Copenhagen 1947, Copenhagen refers to shaped planning introduced, requirements land development along narrow of finger corridor concentrated, refers to shaped planning guide big Copenhagen area along track traffic line clear defined of corridor for Metro development, through track traffic and city development of integration, will along development concentrated in track station around a km around, around track site land implementation integrated intensive development, and provides good of non-mobile of way received connection facilities, Ensure that a larger proportion of the region's residents commute using mass transit. Figure 5.1-3 Copenhagen Metro City Development 2, Tokyo 5.1-4 Tokyo Metro to guide regional development (left: 1950, right: 2000) formation is the mass transit system of the city of Tokyo, which have been developed under the guidance of. Eastern suburbs ... Established to track traffic based on the network-city, using rail-oriented intensive development mode has been recognized in many cities. Created the urban structure of the node, forming the urban rail transit-dependent and lifestyle, as well as mass transit systems provide adequate passenger protection. 5.1.3 to guide the healthy development of 使用A(m)=[]形式可对矩阵元素作任意删除,但结果是将剩下的元素重构成一个行向量。 A=magic(4) A(:,2)=[] %删除矩阵A的第二列元素 A(2,1)=[] %错误 A(5)=[] %结果 A变成了一个15元素的行向量 2.6.2 重塑矩阵 2.6.2 重塑矩阵 2.6.2 重塑矩阵 重塑矩阵函数 函数 功能 reshape 重塑矩阵 rot90 逆时针旋转矩阵90度 fliplr 沿Y轴翻转矩阵 flipud 沿X轴翻转矩阵 flipdim 沿指定方向翻转矩阵 transpose 沿主对角线翻转矩阵 ctranspose 转置矩阵 下例演示表中函数的使用。 A=[1 4 7 10;2 5 8 11;3 6 9 12] B=reshape(A,2,6) %3×4 => 2×6重构后矩阵存贮结构不变 C= rot90(A) %将矩阵A逆时针旋转90度。 D=fliplr(A) %沿Y轴(左右)翻转矩阵 E=ctranspose(A) %等价于A’ 注:转置矩阵:有点撇符 .' 和撇符 ' 两个转置符号,其中函数ctranspose和 ' 等价。对于实矩阵,二者没有区别,对于复矩阵,点撇符 .' 只转置,撇符 ' 转置后再对每元素求共轭。 layout development cities in developed countries show that developing rail transit Guide and an important means of achieving sustainable urban development. More than the bulk of the urban rail transit vehicles, rail traffic in the urban space layout and guide the evacuation, optimizing the structure and other aspects also play an important role in its role as the scale becomes more important. Rail transit on land development and stimulation is achieved through its good accessibility, under the dual role of mechanisms in land and planning, transport accessibility high land along the rail transit development and high strength, promotion of urban morphology and land use patterns to adjust accordingly. 1, and Copenhagen 1947, Copenhagen refers to shaped planning introduced, requirements land development along narrow of finger corridor concentrated, refers to shaped planning guide big Copenhagen area along track traffic line clear defined of corridor for Metro development, through track traffic and city development of integration, will along development concentrated in track station around a km around, around track site land implementation integrated intensive development, and provides good of non-mobile of way received connection facilities, Ensure that a larger proportion of the region's residents commute using mass transit. Figure 5.1-3 Copenhagen Metro City Development 2, Tokyo 5.1-4 Tokyo Metro to guide regional development (left: 1950, right: 2000) formation is the mass transit system of the city of Tokyo, which have been developed under the guidance of. Eastern suburbs ... Established to track traffic based on the network-city, using rail-oriented intensive development mode has been recognized in many cities. Created the urban structure of the node, forming the urban rail transit-dependent and lifestyle, as well as mass transit systems provide adequate passenger protection. 5.1.3 to guide the healthy development of 2.7 导入数据2.7 导入数据2.7 导入数据 2.7.1 使用load命令导入数据 2.7.1 使用load命令导入数据 2.7.1 使用load命令导入数据 使用 load 命令可导入 .txt、.dat类型的文本文件。数据被保存在与文件名同名的矩阵中。注意,必须是矩形文本。使用 load 命令可导入.mat 类型的内存变量文件。命令中可省去扩展名.mat。 load filename 2.7.2 使用 Ipput wizard 工具 2.7.2 使用 Ipput wizard 工具 2.7.2 使用 Ipput wizard 工具 菜单:Start—Matlab—Input wizard 依提示导入MATLAB 能识别的数据。如Excel 文件、图像等。 2.8 矩阵的代数运算 2.8 矩阵的代数运算 2.8 矩阵的代数运算 1、+ ,:加减运算,对应位置元素相加减 2、乘法(数学上叫叉乘) 1?*:叉乘,A(m×t)*B(t×n)=C(m×n) 2? .*:点乘,对应位置元素相乘 注:加减运算,点乘运算要求两个矩阵为同型矩阵(两个行数、列数对应相同的矩阵) 例:乘法和加法运算 A=[1 2 3; 4 5 6]; B=[1 2 3 4;5 6 7 8;8 10 11 12]; C=A*B D=A.*A E=A+A 3、除法运算 layout development cities in developed countries show that developing rail transit Guide and an important means of achieving sustainable urban development. More than the bulk of the urban rail transit vehicles, rail traffic in the urban space layout and guide the evacuation, optimizing the structure and other aspects also play an important role in its role as the scale becomes more important. Rail transit on land development and stimulation is achieved through its good accessibility, under the dual role of mechanisms in land and planning, transport accessibility high land along the rail transit development and high strength, promotion of urban morphology and land use patterns to adjust accordingly. 1, and Copenhagen 1947, Copenhagen refers to shaped planning introduced, requirements land development along narrow of finger corridor concentrated, refers to shaped planning guide big Copenhagen area along track traffic line clear defined of corridor for Metro development, through track traffic and city development of integration, will along development concentrated in track station around a km around, around track site land implementation integrated intensive development, and provides good of non-mobile of way received connection facilities, Ensure that a larger proportion of the region's residents commute using mass transit. Figure 5.1-3 Copenhagen Metro City Development 2, Tokyo 5.1-4 Tokyo Metro to guide regional development (left: 1950, right: 2000) formation is the mass transit system of the city of Tokyo, which have been developed under the guidance of. Eastern suburbs ... Established to track traffic based on the network-city, using rail-oriented intensive development mode has been recognized in many cities. Created the urban structure of the node, forming the urban rail transit-dependent and lifestyle, as well as mass transit systems provide adequate passenger protection. 5.1.3 to guide the healthy development of 由于矩阵乘法不满足交换律(即A*B?B*A),通常有以下两个方程 a*x =b,此时x=a\b(b左除a) x*a=b,此时x=b/a(b右除a,或简称b除a) 如果a为非奇异矩阵(行列式不为零的矩阵),则a\b和b/a可通过a的逆矩阵与b阵得到: a\b = inv(a)*b % inv 求矩阵的逆,左乘a的逆 b/a = b*inv(a) %右乘a的逆 xy(另外,y.\x 和 y./x运算,两个矩阵对应位置元素作 运算)。 和yx 4、矩阵和常数的运算:矩阵中的每个元素和这个常数进行通常意义下的算术运算。 2.9 矩阵的逻辑运算 2.9 矩阵的逻辑运算 2.9 矩阵的逻辑运算 逻辑运算符 操作符 说明 等价的函数 & 逻辑与 and(x,y) | 逻辑或 or(x,y) ~ 逻辑非 not(x) 函数中的x与y可以都是矩阵或向量,也可以有一个是标量。要求它们的大小完全相同(即要求是同型矩阵)。 layout development cities in developed countries show that developing rail transit Guide and an important means of achieving sustainable urban development. More than the bulk of the urban rail transit vehicles, rail traffic in the urban space layout and guide the evacuation, optimizing the structure and other aspects also play an important role in its role as the scale becomes more important. Rail transit on land development and stimulation is achieved through its good accessibility, under the dual role of mechanisms in land and planning, transport accessibility high land along the rail transit development and high strength, promotion of urban morphology and land use patterns to adjust accordingly. 1, and Copenhagen 1947, Copenhagen refers to shaped planning introduced, requirements land development along narrow of finger corridor concentrated, refers to shaped planning guide big Copenhagen area along track traffic line clear defined of corridor for Metro development, through track traffic and city development of integration, will along development concentrated in track station around a km around, around track site land implementation integrated intensive development, and provides good of non-mobile of way received connection facilities, Ensure that a larger proportion of the region's residents commute using mass transit. Figure 5.1-3 Copenhagen Metro City Development 2, Tokyo 5.1-4 Tokyo Metro to guide regional development (left: 1950, right: 2000) formation is the mass transit system of the city of Tokyo, which have been developed under the guidance of. Eastern suburbs ... Established to track traffic based on the network-city, using rail-oriented intensive development mode has been recognized in many cities. Created the urban structure of the node, forming the urban rail transit-dependent and lifestyle, as well as mass transit systems provide adequate passenger protection. 5.1.3 to guide the healthy development of
本文档为【第2章 数组和矩阵】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_633423
暂无简介~
格式:doc
大小:74KB
软件:Word
页数:0
分类:生活休闲
上传时间:2017-11-26
浏览量:10