MATLAB 2020a向三维向量信号加入噪声——高斯白噪声/泊松噪声

问题

使用matlab向已有的三维信号,如Y = (32,32,512)中的每一个向量(1,1,512)加入特定分布的噪声。

 

1. 高斯白噪声

使用AWGN函数向Y加高斯白噪声。

AWGN函数的用法

基础知识

dBw与dBm: dBw 与dBm一样,dBw是一个表示功率绝对值的单位(以1W功率为基准,dBm是以1mW为基准)。

\mathrm{dBw}=10 \lg \left(\frac{P}{1 \mathrm{w}}\right)

信噪比: 信噪比的计量单位是dB,其计算方法是10lg(Ps/Pn),其中Ps和Pn分别代表信号和噪声的有效功率,也可以换算成电压幅值的比率关系:20Lg(Vs/Vn),Vs和Vn分别代表信号和噪声电压的“有效值”。

 

Description

来自:matlab官方文档

out = awgn(in,snr) adds white Gaussian noise to the vector signal in. This syntax assumes that the power of in is 0 dBW.

example

out = awgn(in,snr,signalpower) accepts an input signal power value in dBW. To have the function measure the power of in before adding noise, specify signalpower as 'measured'.

example

out = awgn(in,snr,signalpower,randobjectaccepts input combinations from prior syntaxes and a random number stream object to generate normal random noise samples. For information about producing repeatable noise samples, see Tips.

out = awgn(in,snr,signalpower,seed) specifies a seed value for initializing the normal random number generator that is used when adding white Gaussian noise to the input signal. For information about producing repeatable noise samples, see Tips.

out = awgn(___,powertype) specifies the signal and noise power type as 'dB' or 'linear' in addition to the input arguments in any of the previous syntaxes.

For the relationships between SNR and other measures of the relative power of the noise, such as Es/N0, and Eb/N0, see AWGN Channel Noise Level.

即:

  • out = awgn(in,snr): 向向量信号in中加入信噪比为snr dB的高斯噪声。其中,snr dB的信噪比是在默认in的功率为0dBW(即1W)时计算的.
  • out = awgn(in,snr,signalpower): 向向量信号in中加入信噪比为snr dB的高斯噪声。其中,snr dB的信噪比是在in的功率为signapowelr dBW计算的. 如果想让matlab自己测量in的功率并用于计算,则应该设置signalpower 为 'measured';
  • out = awgn(in,snr,signalpower,randobject): 在out = awgn(in,snr,signalpower)的基础上,使用来自先前语法和RandStream对象的输入组合以生成正态随机噪声样本;其中,随机数流对象RandStream的含义为:

MATLAB® 中的伪随机数来自一个或多个随机数流。生成随机数数组的最简单方法是使用 randrandn 或 randi。这些函数全部都依赖于同一均匀随机数流,称为全局流。您可以创建与全局流分开使用的其他流,使用它们的 randrandi 或 randn 方法生成随机数数组。您也可以创建随机数流并将其用作全局流。

要创建单个随机数流,请使用 RandStream 构造函数。要创建多个独立的随机数流,请使用 RandStream.createrng 函数提供一个用于新建全局流的简单接口。

stream = RandStream.getGlobalStream 返回全局随机数流,即 randrandi 和 randn 函数当前使用的数流。

prevstream = RandStream.setGlobalStream(stream) 将随机数流 stream 指定为 randrandi 和 randn 函数要使用的新全局流,并返回上一全局流。

  • out = awgn(in,snr,signalpower,seed) : 指定创建随机数时的初始值。
  • out = awgn(___,powertype): powertype用于规定snr和signalpower:
    • 当powertype时'dB'时(默认): snr单位为dB. signalpower单位为dBw;
    • 当powertype为’linear‘时,snr为比率,signalpower单位为瓦特;

应用

由于实际实验中的in信号代表的含义为单位时间检测并计数到的光子数量,难以计算功率,因此决定假设单位时间每到达一个有用的光子代表"1W的功率"; 同理,单位时间每到达一个环境噪声光子代表"1W的噪声";

这样,可通过如下代码完成向已有的信号加入信噪比为0.5dB的噪声,其中原始信号功率由matlab自动测量得到,则代码如下:

Y1 = awgn(Y, 0.5, 'measured')

 

2. Poisson噪声

使用poissrnd函数产生泊松噪声。

泊松分布的概率函数为:

P(X=k)=\frac{\lambda^{k}}{k !} e^{\lambda}, k=0,1, \cdots

 

泊松分布的参数λ是单位时间(或单位面积)内随机事件的平均发生次数。 泊松分布适合于描述单位时间内随机事件发生的次数。

泊松分布的期望方差均为λ

 

结合poissrnd的帮助:

poissrnd - Random numbers from Poisson distribution

    This MATLAB function generates random numbers from the Poisson distribution
    specified by the rate parameter lambda.

    r = poissrnd(lambda)
    r = poissrnd(lambda,sz1,...,szN)
    r = poissrnd(lambda,sz)

因此,若要对向量X加入泊松噪声得到向量Y,只需要Y = poissrnd(X)即可;

 

 

总结

  • 高斯白噪声的分布与信号分布无关,加入时应注意设置信噪比等参数,并且注意单位的设置;
  • 泊松噪声的分布由信号分布决定,因此无需设置方差、均值等分布参数;
  • 但总觉得还有更合适的泊松噪声添加方法,待日后补充;

 

 

======================================================================================================

原载于 我的博客

如有错误,请联系 rxnlos@126.com

======================================================================================================

 

 

 

 

 

 

 

 

  • 3
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

R.X. NLOS

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值