简体   繁体   English

BPSK调制和SNR:Matlab

[英]BPSK modulation and SNR : Matlab

Considering an Additive White Gaussian Noise (AWGN) communication channel where a signal taking values from BPSK modulation is being transmitted. 考虑一个加性高斯白噪声(AWGN)通信信道,在该信道中传输从BPSK调制中获取值的信号。 Then, the received noisy signal is : y[k] = s[k] + w[k] where s[k] is either +1,-1 symbol and w[k] is the zero mean white gaussian noise. 然后,接收到的噪声信号为: y[k] = s[k] + w[k]其中s[k]为+ 1,-1符号, w[k]为零平均高斯白噪声。

-- I want to estimate the signal s and evaluate the performance by varing SNR from 0:40 dB. -我想估计信号s并通过从0:40 dB改变SNR来评估性能。 Let, the estimated signal be hat_s . 假设估计信号为hat_s

So, the graph for this would have on X axis the SNR range and on Y Axis the Mean Square Error obtained between the known signal values and the estimates ie, s[k] - hat_s[k] 因此,该图在X轴上具有SNR范围,在Y轴上具有在已知信号值和估计值之间获得的均方误差,即s[k] - hat_s[k]

Question 1: How do I define signal-to-noise ratio? 问题1:如何定义信噪比? Would the formula of SNR be sigma^2/sigma^2_w . SNR的公式为sigma^2/sigma^2_w I am confused about the term in the numerator: what is the variance of the signal, sigma^2, usually considered? 我对分子中的术语感到困惑:通常考虑的信号方差sigma ^ 2是多少?

Question 2: But, I don't know what the value of the variance of the noise is, so how does one add noise? 问题2:但是,我不知道噪声方差的值是多少,那么一个噪声如何增加?

This is what I have done. 这就是我所做的。

N = 100; %number of samples
s = 2*round(rand(N,1))-1;
 %bpsk modulation
y = awgn(s,10,'measured'); %adding noise but I don't know
the variance of the signal and noise 

%estimation using least squares

hat_s = y./s;


 mse_s = ((s-hat_s).^2)/N;

Please correct me where wrong. 请在错误的地方纠正我。 Thank you. 谢谢。

First I think that it is important to know what are the things we have an a BPSK system: 首先,我认为了解BPSK系统的功能很重要:

The constellation of a BPSK system is [-A , A] in this case [-1,1] the SNR will vary from 0 db to 40 db BPSK系统的星座为[-A,A],在这种情况下为[-1,1],SNR将从0 db变化到40 db

I thing that the answer is in this function: 我认为答案在此功能中:

y = awgn( ... ); y = awgn(...); from matlab central: 从Matlab Central:

y = awgn(x,snr) adds white Gaussian noise to the vector signal x. y = awgn(x,snr)将白高斯噪声添加到矢量信号x。 The scalar snr specifies the signal-to-noise ratio per sample, in dB. 标量snr指定每个样本的信噪比,以dB为单位。 If x is complex, awgn adds complex noise. 如果x为复数,则awgn会添加复数噪声。 This syntax assumes that the power of x is 0 dBW. 此语法假定x的功率为0 dBW。

y = awgn(x,snr,sigpower) is the same as the syntax above, except that sigpower is the power of x in dBW. y = awgn(x,snr,sigpower)与上面的语法相同,除了sigpower是x的功率(以dBW为单位)。

y = awgn(x,snr,'measured') is the same as y = awgn(x,snr), except that awgn measures the power of x before adding noise. y = awgn(x,snr,'measured')与y = awgn(x,snr)相同,除了awgn在添加噪声之前测量x的幂。

you use y = awgn(x,snr,'measured'), so you do not need to worry, beacuse matlab carries all for you, measure the power of the signal, and then apply to channel a noise with the variance needed to get that SNR ratio. 您使用y = awgn(x,snr,'measured'),因此您无需担心,因为matlab为您提供了所有功能,测量了信号的功率,然后将其用于获得噪声所需的方差信噪比。

let's see how can this happen 让我们看看这怎么发生

SNRbit = Eb/No = A^2/No = dmin^2 /4N0

the constelation [A,-A] in this case is [-1,1] so

10 log10(A^2/N0) = 10 log10(1/N0) = SNRbitdb

SNRlineal = 10^(0.1*SNRdb)

so with that: 因此:

noise_var=0.5/(EbN0_lin); % s^2=N0/2

and the signal will be something like this 信号将是这样的

y = s + sqrt(noise_var)*randn(1,size);

so in your case, I will generate the signal as you do: 因此,在您的情况下,我将像您一样生成信号:

>> N = 100; %number of samples
>> s = 2*round(rand(N,1))-1; %bpsk modulation

then prepare a SNR varies from 0 to 40 db 然后准备SNR在0到40 db之间变化

>> SNR_DB = 0:1:40;

after that calulating all the posible signals: 之后,计算所有可能的信号:

>> y = zeros(100,length(SNR_DB));

>> for i = 1:41
y(:,i) = awgn(s,SNR_DB(i),'measured');
end

at this point the best way to see the signal is using a constellation plot like this: 此时,查看信号的最佳方法是使用星座图,如下所示:

>> scatterplot(y(:,1));
>> scatterplot(y(:,41));

散点图40 db

散点图0 db

you can see a bad signal 0 db noise equal power as signal and a very good signal signal bigger than 40 DB noise. 您会看到不良信号0 db噪声等于信号功率,而非常好的信号大于40 DB噪声。 Eb/No = Power signal - Power noise db, so 0 means power noise equal to power of signal, 40 db means power of signal bigger bigger bigger than power of noise Eb / No =功率信号-功率噪声db,因此0表示功率噪声等于信号功率,40 db表示信号功率大于或大于噪声功率

then for you plot calculate the mse, matlab has one function for this 然后为您绘图计算mse,matlab为此提供了一个功能

err = immse(X,Y) Description err = immse(X,Y)说明

example

err = immse(X,Y) calculates the mean-squared error (MSE) between the arrays X and Y. X and Y can be arrays of any dimension, but must be of the same size and class. err = immse(X,Y)计算数组X和Y之间的均方误差(MSE)。X和Y可以是任何维度的数组,但必须具有相同的大小和类。

so with This: 所以这样:

>> for i = 1:41
err(i) = immse(s,y(:,i));
end
>> stem(SNR_DB,err)

在此处输入图片说明

For plots, and since we are working in db, it should be beeter to use logarithmic axes 对于绘图,由于我们在db中工作,因此最好使用对数轴

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM