Matlab 之 几个随机函数-randperm,rand,randn,randint
来源:互联网 发布:哪些手机支持4g十网络 编辑:程序博客网 时间:2024/05/19 18:42
1.randperm( )
Matlab自带函数randperm(n)产生1到n的整数的无重复的随机排列,利用它就可以得到无重复的随机数。
>>randperm(6)
ans =
5 2 6 4 1 3
>>randperm(6,3)
ans =
2 6 4
2. rand( )
(1)rand(n):生成均匀分布的0到1之间的n*n的随机数方阵
(2)rand(m,n):生成0到1之间的m×n的随机数矩阵
>>rand(5,4)
ans =
0.8617 0.1692 0.9155 0.0553
0.0326 0.9522 0.8956 0.7538
0.3320 0.5433 0.4825 0.1319
0.7487 0.2514 0.4427 0.3559
0.6444 0.5786 0.3118 0.3959
3. randn
randn()命令是产生白噪声的,白噪声应该是0均值,方差为1的一组数,同rand有randn(n),randn(m,n)
rand是0-1的均匀分布,randn是均值为0方差为1的正态分布
>>randn(5)
ans =0.8451 -0.0087 0.1973 0.6211 0.0705
-2.7712 0.2334 -0.7069 -1.7955 -1.9330
0.9181 -0.4242 1.2164 -1.0578 0.8187
-0.5193 -1.4694 0.3672 0.1515 1.2618
-1.2930 1.2064 -1.2675 0.4113 1.1673
4. randint
randint(m,n,[1 N]):生成m×n的在1到N之间的随机整数矩阵,其效果与randint(m,n,N+1)相同。
>> randint(3,4,[1 10])
ans =
5 7 4 10
5 1 2 7
8 7 8 6
>> randint(3,4,11)
ans =
10 9 6 9
5 10 8 9
10 0 2 6
阅读全文
0 0
- Matlab 之 几个随机函数-randperm,rand,randn,randint
- Matlab中的几个随机函数-randperm,sort,rand,randint
- Matlab中的几个随机函数-randperm,sort,rand,randint
- rand, randn和randint函数的区别(MATLAB)
- Matlab_learning_4(rand randn randint函数 )
- randn,randperm,rand
- Matlab中随机函数:rand函数,randn函数,randi函数
- matlab常用随机函数randperm
- matlab函数rand,randn,randi用法整理
- MATLAB之randn函数
- Python的numpy库中rand(),randn(),randint(),random_integers()等random系函数的使用
- MATLAB随机函数rand
- rand和randn函数
- matlab随机函数rand()使用
- matlab中的randperm函数
- matlab randint函数
- matlab函数randn
- MATLAB函数randn简介
- CSS
- 前端开发中的兼容性问题-CSS篇
- IDEA项目无法识别maven
- 递归思想
- gfoj987约数统计
- Matlab 之 几个随机函数-randperm,rand,randn,randint
- linux中 oracle 创建用户和表空间以及授权
- meta标签中的minimal-ui
- Go语言接口
- Python之Math
- SpringMvc入门概述
- css实现div的水平垂直居中方法
- vs2013 c++调用lua
- eclipse中设置编码格式