• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Matlab函数

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

any() 相当于或操作,只要有1,就返回1

 

all() 相当于与操作,只要有0,就返回0

 

 

 

 C = union(A,B):

 

 C为A和B的并集。去掉相同元素。

 

C = intersect(A,B)

 

C为A和B的交集. The values of C are in sorted order.

 

 

 

[Lia,Locb] = ismember(A,B):

 

  判断A中元素是否为B中的子元素,如果不是则,Lia和Locb中元素值都为0(注意,Lia大小和A一样,Locb大小和B一样)。如果A中有元素是B中的,在Lia中对应返回值1,Locb, containing the highest index in B for each value in A that is a member of B. The output array, Locb, contains 0 wherever A is not a member of B.

 

[C,ia] = setdiff(A,B):

 

  返回的C元素为在A中出现,但是没有在B中出现,ia为其索引值,满足C = A(ia)。

 

 

 

D = D(:)'; % ensure that D is a row vector

 

D(:)按列将矩阵变为列向量

 

 

 

 

 

reshape是根据原来的矩阵创造新的矩阵,repmat是将原来的矩阵复制多次,构成一个大矩阵。

 

>> A=magic(4)

 

A =

 

16 2 3 13

5 11 10 8

9 7 6 12

4 14 15 1

 

B = reshape(A,...,[],...) calculates the length of the dimension represented by the placeholder [], such that the product of the dimensions equals prod(size(A)). The value of prod(size(A)) must be evenly divisible by the product of the specified dimensions. You can use only one occurrence of [].

 

>> reshape(A,[],2)

 

ans =

 

16 3

5 10

9 6

4 15

2 13

11 8

7 12

14 1

 

 

 

max(a),若a为向量,返回最大值,若a为矩阵,返回每列最大值作为一个向量。

 

C = max(A,B) returns an array the same size as A and B with the largest elements taken from A or B. The dimensions of A and B must match, or they may be scalar.

 

C = max(A,[],dim) returnsthe largest elements along the dimension of A specifiedby scalar dim. For example, max(A,[],1) producesthe maximum values along the first dimension of A.

 

[C,I] = max(...) finds the indices of the maximum values of A, and returns them in output vector I. If there are several identical maximum values, the index of the first one found is returned.

 

K>> c=magic(4)

 

c =

 

16 2 3 13

5 11 10 8

9 7 6 12

4 14 15 1

 

K>> max(c) 等同于max(c,[],1)

 

ans =

 

16 14 15 13

 

 

K>> max(c,[],2)

 

ans =

 

16

11

12

15

 

 

 

K>> [m,n]=max(c,[],2)

 

m =

 

16

11

12

15

 

 

n =

 

1

2

4

3

find; sparse;full

[i,j,s] = find(S);
[m,n] = size(S);
S = sparse(i,j,s,m,n);

对于稀疏矩阵,i,j分别是不为零项的index,s是其值

 


So does this, if the last row and column have nonzero entries:

[i,j,s] = find(S);
S = sparse(i,j,s);

 

 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
浅谈Delphi过程与函数02 - 零基础入门学习Delphi21发布时间:2022-07-18
下一篇:
Delphi-基础(for循环)发布时间:2022-07-18
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap