Matlab中rand('state',s)和rand('state',0)
2014-04-17 14:29
302 查看
RAND('state',0) resets the generator to its initial state.
RAND('state',J), for integer J, resets the generator to its J-th state.
RAND('state',J) and RAND('state',S) cause the MATLAB 5 generator to be used.
help 里面解释
rand('state',s)Resets the state to s.
rand('state',0)Resets the generator to its initial state.
rand('state',j)For integer j, resets the generator to its j-th state.
用法:
(一)rand('state',s)表示随机产生数的状态state,一般情况下不用指定状态。但是有的书籍作者为了让读者能够看到和他书本的同样结果,采用了设置state,rand('state',0)。作用在于如果指定状态,产生随机结果就相同了。
(二)因为每次rand产生的随机数都不一样,在产生之后,为了得到与前面某个状态相同的结果,用这个函数来产生该相同的随机数
如:>> a=rand(3,1)
a =
0.4565
0.0185
0.8214
>> a=rand(3,1)
a =
0.4447
0.6154
0.7919
>> a=rand(3,1)
a =
0.9218
0.7382
0.1763
而
>> rand('state',0)
>> a=rand(3,1)
a =
0.9501
0.2311
0.6068
>> rand('state',0)
>> a=rand(3,1)
a =
0.9501
0.2311
0.6068
>> rand('state',0)
>> a=rand(3,1)
a =
0.9501
0.2311
0.6068
RAND('state',0) resets the generator to its initial state.
RAND('state',J), for integer J, resets the generator to its J-th state.
RAND('state',J) and RAND('state',S) cause the MATLAB 5 generator to be used.
help 里面解释
rand('state',s)Resets the state to s.
rand('state',0)Resets the generator to its initial state.
rand('state',j)For integer j, resets the generator to its j-th state.
用法:
(一)rand('state',s)表示随机产生数的状态state,一般情况下不用指定状态。但是有的书籍作者为了让读者能够看到和他书本的同样结果,采用了设置state,rand('state',0)。作用在于如果指定状态,产生随机结果就相同了。
(二)因为每次rand产生的随机数都不一样,在产生之后,为了得到与前面某个状态相同的结果,用这个函数来产生该相同的随机数
如:>> a=rand(3,1)
a =
0.4565
0.0185
0.8214
>> a=rand(3,1)
a =
0.4447
0.6154
0.7919
>> a=rand(3,1)
a =
0.9218
0.7382
0.1763
而
>> rand('state',0)
>> a=rand(3,1)
a =
0.9501
0.2311
0.6068
>> rand('state',0)
>> a=rand(3,1)
a =
0.9501
0.2311
0.6068
>> rand('state',0)
>> a=rand(3,1)
a =
0.9501
0.2311
0.6068
相关文章推荐
- matlab中用rng替换rand('seed',sd)、randn('seed',sd)和rand('state',sd)的通俗解释
- matlab rand(‘state’,42)
- Matlab产生随机数函数rand和randn的“state”和“seed”参数
- Matlab中rand('state',sum(clock))解析
- Matlab产生随机数函数rand和randn的“state”和“seed”参数
- MATLAB——rand 与 randn 'twister'、'state'、'seed'
- Matlab产生随机数函数rand和randn的“state”和“seed”参数
- Matlab中的RandStream的应用场景
- Matlab中的rand(),magic()
- Matlab之randn
- Matlab中rand('state',sum(clock))解析
- 产生随机数rand和randn中的“state”、“seed”和"twister"参数
- MATLAB随机函数rand
- MATLAB随机函数rand
- matlab rand(‘seed’,key)函数,是用来做什么的呀
- matlab中rand的高级用法
- matlab随机函数rand使用中应注意的问题
- matlab rand, randn, randi
- matlab eps scope simulink stateflow latex paper
- Matlab的rand(),randn()和randi()函数问题