本文主要是介绍matlab awgn函数加入高斯白噪声,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
信噪比
信噪比,电子设备或者通信系统中有效信号和噪声的比值,英文名称叫做SNR
或S/N
(SIGNAL-NOISE RATIO
);
awgn描述
awgn函数可以将白色高斯噪声添加到信号中。
语法
y = awgn(x,snr)
y = awgn(x,snr,sigpower)
y = awgn(x,snr,'measured')
y = awgn(x,snr,sigpower,state)
y = awgn(x,snr,'measured',state)
y = awgn(...,powertype)
描述
- y = awgn(x,snr)将白高斯噪声添加到向量信号x中。标量snr指定了每一个采样点信号与噪声的比率,单位为dB。如果x是复数的,awgn将会添加复数噪声。这个语法假设x的能量是0dBW。
- y = awgn(x,snr,sigpower)和上面的语法相同,除了sigpower是x的能量,单位为dBW。
- y = awgn(x,snr,‘measured’)和y = awgn(x,snr)是相同的,除了agwn在添加噪声之前测量了x的能量。
- y = awgn(x,snr,sigpower,state)和y = awgn(x,snr,sigpower)是相同的,除了awgn首先重置了正态随机数产生器randn的状态为整数状态。
- y = awgn(x,snr,‘measured’,state)和y = awgn(x,snr,‘measured’)是相同的,除了awgn首先重置了正态随机数产生器randn的状态为整数状态。
- y = awgn(…,powertype)和前面的语法相同,除了字符串powertype指定了snr和sigpower的单位。powertype的选择有’db’ and ‘linear’,如果powertype是’db’,那么snr是按照dB为单位测量的,sigpower是按照dBW为单位测量的。如果powertype是线性的,snr是按照一个比率测量的,sigpower是以瓦特为单位测量的。Relationship Among SNR, Es/N0, and Eb/N0
对于SNR和其他的噪声相对能量测量的关系,查看Describing the Noise Level of an AWGN Channel。
例子
% Example 1: % To specify the power of X to be 0 dBW and add noise to produce% an SNR of 10dB, use:X = sqrt(2)*sin(0:pi/8:6*pi);Y = awgn(X,10,0);% Example 2: % To specify the power of X to be 3 Watts and add noise to% produce a linear SNR of 4, use:X = sqrt(2)*sin(0:pi/8:6*pi);Y = awgn(X,4,3,'linear');% Example 3: % To cause awgn to measure the power of X and add noise to% produce a linear SNR of 4, use:X = sqrt(2)*sin(0:pi/8:6*pi);Y = awgn(X,4,'measured','linear');% Example 4: % To specify the power of X to be 0 dBW, add noise to produce% an SNR of 10dB, and utilize a local random stream, use:S = RandStream('mt19937ar','seed',5489);X = sqrt(2)*sin(0:pi/8:6*pi);Y = awgn(X,10,0,S);% Example 5: % To specify the power of X to be 0 dBW, add noise to produce% an SNR of 10dB, and produce reproducible results, use:reset(RandStream.getGlobalStream)X = sqrt(2)*sin(0:pi/8:6*pi);Y = awgn(X,10,0,S);
matlab 程序 正弦+白噪声
f1=50; % 频率
fs=1000; % 采样频率
Ts=1/fs; % 采样间隔
N=200; % 采样点数
n=1:N;
y=sin(2*pi*f1*n*Ts);
snr=30; % 信噪比
r=awgn(y,snr);
subplot(2,1,1);
plot(y,'black')
axis([-inf,inf,-2,2,])
title('原信号');
subplot(2,1,2);
%hold on
plot(r,'black')
axis([-inf,inf,-2,2,])
title('原信号+高斯噪声');
SNR=10
SNR=20
SNR=30
matlab 程序 锯齿波+噪声
t = 0:.1:20;
x = sawtooth(t); % Create sawtooth signal.
snr=10;y = awgn(x,snr,'measured'); % Add white Gaussian noise.
subplot(1,3,1);
plot(t,x,t,y) % Plot both signals.
legend('Original signal','Signal with AWGN');
axis([-inf,inf,-1.5,1.5,])
title('SNR=10');snr=20;
y = awgn(x,snr,'measured'); % Add white Gaussian noise.
subplot(1,3,2);
plot(t,x,t,y) % Plot both signals.
legend('Original signal','Signal with AWGN');
axis([-inf,inf,-1.5,1.5,])
title('SNR=20');snr=30;
y = awgn(x,snr,'measured'); % Add white Gaussian noise.
subplot(1,3,3);
plot(t,x,t,y) % Plot both signals.
legend('Original signal','Signal with AWGN');
axis([-inf,inf,-1.5,1.5,])
title('SNR=30');
修改信噪比
这篇关于matlab awgn函数加入高斯白噪声的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!