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

Matlab基本命令

原作者: [db:作者] 来自: [db:来源] 收藏 邀请
ones
Create array of all ones
Y = ones(n)
Y = ones(m,n)
Y = ones([m n])
Y = ones(m,n,p,...)
Y = ones([m n p ...])

Y = ones(n) returns an n-by-n matrix of 1s. An error message appears if n is not a scalar.
Y = ones(m,n) or Y = ones([m n]) returns an m-by-n matrix of ones.
Y = ones(m,n,p,...) or Y = ones([m n p ...]) returns an m-by-n-by-p-by-... array of 1s.

 

 

sum
Sum of array elements

B = sum(A)
B = sum(A,dim)
B = sum(..., \'double\')
B = sum(..., dim,\'double\')
B = sum(..., \'native\')
B = sum(..., dim,\'native\')
Description

B = sum(A) returns sums along different dimensions of an array.

If A is a vector, sum(A) returns the sum of the elements.

If A is a matrix, sum(A) treats the columns of A as vectors, returning a row vector of the sums of each column.

If A is a multidimensional array, sum(A) treats the values along the first non-singleton dimension as vectors, returning an array of row vectors.
 

 

size

Array dimensions

d = size(X)
[m,n] = size(X)
m = size(X,dim)
[d1,d2,d3,...,dn] = size(X),
Description

d = size(X) returns the sizes of each dimension of array X in a vector d with ndims(X) elements. If X is a scalar, which MATLAB regards as a 1-by-1 array, size(X) returns the vector [1 1].

[m,n] = size(X) returns the size of matrix X in separate variables m and n.

m = size(X,dim) returns the size of the dimension of X specified by scalar dim.

 

 

randn

Normally distributed random numbers

Y = randn
Y = randn(n)
Y = randn(m,n)
Y = randn([m n])
Y = randn(m,n,p,...)
Y = randn([m n p...])
Y = randn(size(A))
randn(method,s)
s = randn(method)
Description

Y = randn returns a pseudorandom, scalar value drawn from a normal distribution with mean 0 and standard deviation 1.

Y = randn(n) returns an n-by-n matrix of values derived as described above.
Y = randn(m,n) or Y = randn([m n]) returns an m-by-n matrix of the same.
Y = randn(m,n,p,...) or Y = randn([m n p...]) generates an m-by-n-by-p-by-... array of the same.
 

 

 生成特殊矩阵

产生10*10的全0矩阵: zeros(10,10) 
产生10*10的全1矩阵: ones(10,10)
产生10*10的单位矩阵: eye(10,10)
产生10*10的0~1间均匀分布的随机矩阵。 rand(10,10)
产生10*10的均值为0,方差为1的标准正态分布随机矩阵: randn(10,10)

 


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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