简体   繁体   中英

How to add x % noise in a signal in MATLAB?

I am trying to add 5 % noise to a measured signal as follows (in MATLAB), but when I calculate percent of noise after addition, it is beyond +/- 5 %. Can you please tell me why this is the case? Shouldnt it be within a +/- 5 % bound?

 noiseSigma = 0.05 * signal;                % signal is my original signal

信号

noise = noiseSigma .* randn(1, length(signal));

noisySignal = signal + noise;

信号中的噪声

percent_noise = 100*(noisySignal-signal)./signal;

信号中的噪声百分比

randn draws from a normal distribution so it can be larger than 1.

If you want to limit your noise to 5 percent you can try the following:

noise_limit = 0.05 * signal;
addative_noise = noise_limit .* (2*rand(1, length(signal))-1);
result = signal+addative_noise;

This works because rand chooses values between zero and one. multiply it by two and subtract one, and it chooses values between -1 and 1.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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