matlab生成blocks、bumps和doppler标准测试信号
来源:互联网 发布:算法分析的主要方面是 编辑:程序博客网 时间:2024/05/16 10:20
关键函数:wnoise
使用方式
X = wnoise(FUN,N)
[X,XN] = wnoise(FUN,N,SQRT_SNR)
[X,XN] = wnoise(FUN,N,SQRT_SNR,INIT)
X = wnoise(FUN,N) 返回由 FUN给出的信号,长度为2^N,幅值范围[0,1].
[X,XN] = wnoise(FUN,N,SQRT_SNR) ,返回了一个测试信号X,以及一个加噪信号XN,信噪比为
[X,XN] = wnoise(FUN,N,SQRT_SNR,INIT) ,返回了一个测试信号X,以及一个加噪信号XN,信噪比为
六个函数如下
FUN = 1 or ‘blocks’
FUN = 2 or ‘bumps’
FUN = 3 or ‘heavy sine’
FUN = 4 or ‘doppler’
FUN = 5 or ‘quadchirp’
FUN = 6 or ‘mishmash’
举个栗子
% Generate 2^10 samples of ‘Heavy sine’ (item 3).
x = wnoise(3,10);
% Generate 2^10 samples of ‘Doppler’ (item 4) and of
% noisy ‘Doppler’ with a square root of signal-to-noise
% ratio equal to 7.
[x,noisyx] = wnoise(4,10,7);
% To introduce your own rand seed, a fourth
% argument is allowed:
init = 2055415866;
[x,noisyx] = wnoise(4,10,7,init);
% Plot all the test functions.
ind = linspace(0,1,2^10);
for i = 1:6
x = wnoise(i,10);
subplot(6,1,i), plot(ind,x)
end
实践得知,init你可以随心所欲的设置!反正值一样,产生的噪声就一样啦~
因为wnoise 内部调用了randstream
而MATLAB中的伪随机数都是由一个或者多个random number streams产生的,比如常用的
rand, randn, 或者randi. 都是由相同的均匀随机数产生的,这是所谓的 global stream. 常用随机数发生器列表可用 RandStream.list 查看
随机数产生方法:
RandStream 产生随机数流
RandStream.create 产生多个独立的随机数流.
get 获取产生的随机数流的性质.
list 列举随机数产生算法.
set 设置随机数流的参数.
RandStream.getGlobalStream 获取全局随机数流.
RandStream.setGlobalStream 设置全局随机数流.
reset 恢复默认值
rand 产生符合uniform distribution的伪随机数
randn 产生符合standard normal distribution的伪随机数
randi 产生符合uniform discrete distribution的伪随机整数
randperm 给一列数产生随机扰动
举几个栗子
Example 1
Create a single stream and designate it as the current global stream:
s = RandStream(‘mt19937ar’,’Seed’,1);
RandStream.setGlobalStream(s);
Example 2
Create three independent streams:
[s1,s2,s3] = RandStream.create(‘mrg32k3a’,’NumStreams’,3);
r1 = rand(s1,100000,1);
r2 = rand(s2,100000,1);
r3 = rand(s3,100000,1);
corrcoef([r1,r2,r3])
Example 3
Create only one stream from a set of three independent streams, and designate it as the current global stream:
s2 = RandStream.create(‘mrg32k3a’,’NumStreams’,3,…
‘StreamIndices’,2);
RandStream.setGlobalStream(s2);
Example 4
Reset the global random number stream that underlies rand, randi, and randn back to its beginning, to reproduce previous results:
stream = RandStream.getGlobalStream;
reset(stream);
Example 5
Save and restore the current global stream’s state to reproduce the output of rand:
stream = RandStream.getGlobalStream;
savedState = stream.State;
u1 = rand(1,5)
u1 =
0.8147 0.9058 0.1270 0.9134 0.6324
stream.State = savedState;
u2 = rand(1,5)
u2 =
0.8147 0.9058 0.1270 0.9134 0.6324
u2 contains exactly the same values as u1.
Example 6
Reset the global random number stream to its initial settings. This causes rand, randi, and randn to start over, as if in a new MATLAB session:
s = RandStream(‘mt19937ar’,’Seed’,0);
RandStream.setGlobalStream(s);
Example 7
Reinitialize the global random number stream using a seed based on the current time. This causes rand, randi, and randn to return different values in different MATLAB sessions. It is usually not desirable to do this more than once per MATLAB session as it may affect the statistical properties of the random numbers MATLAB produces:
s = RandStream(‘mt19937ar’,’Seed’,’shuffle’);
RandStream.setGlobalStream(s);
Example 8
Change the transformation algorithm that randn uses to create normal pseudorandom values from uniform values. This does not replace or reset the global stream.
stream = RandStream.getGlobalStream;
stream.NormalTransform = ‘inversion’
更多关于产生随机数的小知识,请移步-》上一篇博文
- matlab生成blocks、bumps和doppler标准测试信号
- 用 Matlab 生成待滤波信号
- 可靠信号和不可靠信号的测试
- dbus 信号和方法测试
- 利用MATLAB绘制信号时域波形和信号的频谱
- 第四周工作总结——Matlab生成iBeacon信号
- Matlab生成各种伪随机信号_idinput指令
- Doppler Shift
- 网络性能测试和标准
- MATLAB 生成.avi和.gif
- Goose bumps 鸡皮疙瘩
- 视频测试信号的幅度和饱和度
- Matlab:FIR滤波器设计和音频信号滤波去噪
- 信号处理和模式识别方面的MATLAB工具箱
- 信号处理和模式识别方面的MATLAB工具箱
- 信号处理和模式识别方面的 matlab toolbox
- 信号处理和模式识别方面的MATLAB工具箱
- 《MATLAB在语音信号分析和合成中的应用》
- java 企业网站源码模版 有前后台 springmvc SSM 生成静态化
- Visual Odometry(视觉里程计): StereoScan Dense 3d Reconstruction in Real-time
- pat 1009. Product of Polynomials (25)
- 关于Spring IOC (DI-依赖注入)你需要知道的一切
- JLINK flash timeout.Reset the tatget and try it again 解决
- matlab生成blocks、bumps和doppler标准测试信号
- 数据采集相关软件
- 从系统说起
- PS软件中最两个重难点
- 问题二十九:测试ray tracing中camera几个主要参数
- day19 IO-2 包装流 标准输入输出流 打印流 Properties 对象流和序列化
- 在Tomcat配置JNDI数据源的三种方式
- 402. Remove K Digits
- python数据分析之(3)pandas