You can use the awgn
function in MATLAB to add Additive White Gaussian Noise (AWGN) to a signal. Here is an example code that adds AWGN to a signal and plots the result:
main.m427 chars21 lines
In this example, a sinusoidal signal with a frequency of 1000 Hz is generated and AWGN with a specified Signal-to-Noise Ratio (SNR) is added to it. The resulting noisy signal is then plotted using the plot
function.
Note that SNR_dB
is the desired Signal-to-Noise Ratio in decibels, and measured
is used as the third argument in the awgn
function to automatically estimate and set the SNR based on the signal.
You can modify the parameters and the signal generation part according to your specific needs.
Make sure you have the Signal Processing Toolbox installed, as the awgn
function is part of this toolbox.
gistlibby LogSnag