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.