用matlab算函数,计算中常用的Matlab函数

1.

rand

产生随机数

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.

随机数发生器是有状态的,可以通过保存函数获取当前的状态,这样下次的时候就可以使用当前状态得到相同的随机数。help rand 有个例子:

Example 4: Save the settings for the random number generator used by rand, RANDI, and RANDN, generate 5 values from rand, restore the settings, and repeat those values.

s = rng

u1 = rand(1,5)

rng(s);

u2 = rand(1,5) % contains exactly the same values as u1

当然,我们使用别人的代码时候,有时候没法使用rng,就需要统一状态,所以就需要rand('state',0):这个是都恢复为初始状态。

>> rand('state',0);

>> rand(3,1)

ans =

0.9501

0.2311

0.6068

>> rand('state',0);

>> rand(3,1)

ans =

0.9501

0.2311

0.6068

2 Linux 后台运行Matlab程序

nohupmatlab < inputscript.m > run.log

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值