活在迷宫

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

randn 
Normally distributed random numbers and arrays Syntax 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 
s = randn('state') Description 
The randn function generates arrays of random numbers whose elements are normally distributed with mean 0, variance σ^2 = 1 , and standard deviation σ = 1. 
Y = randn(n) returns an n-by-n matrix of random entries. An error message appears if n is not a scalar. 

Y = randn(m,n) or Y = randn([m n]) returns an m-by-n matrix of random entries. 

Y = randn(m,n,p,...) or Y = randn([m n p...]) generates random arrays. 

Y = randn(size(A)) returns an array of random entries that is the same size as A. 

randn, by itself, returns a scalar whose value changes each time it's referenced. 

s = randn('state') returns a 2-element vector containing the current state of the normal generator. To change the state of the generator: randn('state',s)Resets the state to s. randn('state',0)Resets the generator to its initial state. randn('state',j)For integer j, resets the generator to its jth state. randn('state',sum(100*clock))Resets it to a different state each time.

s = randn('state')返回一个2元素的包含了当前正常generator的行向量,要改变这个gennrator: randn('state',s)重置状态到s,randn('state',0)重置状态到最开始状态,randn('state',j),对于整数j重置到第j个状态,randn('state',sum(100*clock))每次都重置到不同状态.

posted on 2015-03-30 14:13  活在迷宫  阅读(427)  评论(0编辑  收藏  举报