Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
356 views
in Technique[技术] by (71.8m points)

measurement - 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

signal

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

noisySignal = signal + noise;

Noise in signal

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

percent of noise in signal


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.9k users

...