2017-11-18 71 views
0

我對Matlab很陌生,我有點卡住了。將標準偏差爲1.75的AWG噪聲添加到Matlab生成的信號中

這就是問題所要求的。

將標準偏差爲1.75的AWG噪聲添加到剛剛生成的信號中。

這是信號的代碼:

fs = 20000; %Sample Rate (Hz) 
f = 1200; %frequency of signal 
A = 2.5; % amplitude of signal 
phi = pi/4; 
t = [0:(1/fs):0.05] ; 
y = A * sin (2 * pi * f * t + phi) + 3; 
% sine wave 1 [Hz], phase shift 0°, amplitude of 1 vpp 
plot (t, y); %Plot the waveform you just created 
%Label the axis and title the plot 
xlabel ('time [sec]'); 
ylabel ('amplitude [volt]'); 
xlim([0 0.05]) 
ylim([0 6]) 

回答

0

可以產生高斯噪聲樣本的1.75爲標準偏差 '1.75 * randn(1,numel(Y))'。命令「randn」產生均值= 0和標準差的高斯僞隨機數= 1。這裏是您的代碼具有添加高斯噪聲:

 fs = 20000; %Sample Rate (Hz) 

     f = 1200; %frequency of signal 

     A = 2.5; % amplitude of signal 

     phi = pi/4; 

     t = [0:(1/fs):0.05] ; 

     y = A * sin (2 * pi * f * t + phi) + 3; % sine wave 1 [Hz], phase shift 0°, amplitude of 1 vpp 

     n = 1.75 * randn(1, numel(y)); % AWGN with a standard deviation of 1.75 

     fprintf('The standard deviation of the added noise is %f \n ', std(n)); 

     figure; 

     plot (t, y); %Plot the waveform you just created 

     %Label the axis and title the plot 

     xlabel ('time [sec]'); 

     ylabel ('amplitude [volt]'); 

     xlim([0 0.05]) 

     ylim([0 6]) 

     figure; 

     plot(t, y + n); 

     xlabel ('time [sec]'); 

     ylabel ('amplitude [volt]'); 

噪聲的標準偏差與每一個運行顯著變化。如果您在't'中增加樣本數量,則生成噪聲的標準偏差將非常穩定。

+0

謝謝,我真的很感激。 – Ali