How to add a noise in my Input graph?

I have a input signal and i want to add noise to it with zero mean, variance of deviation = 1, sampling time is 600 and maxi deviation (%) is 15. Kindly help?

 Accepted Answer

hosein Javan
hosein Javan on 13 Aug 2020
Edited: hosein Javan on 13 Aug 2020
this code gives a zero mean noise with a sampling rate equal to your signal. just calculate it's amplitude by knowing variance.
t = linspace(0,2*pi,100);
x = sin(t);
an = 0.2; % noise amplitude
noise = an*(rand(size(x))-0.5);
plot(t,x,'r','linewidth',1)
hold on
plot(t, x+noise)

6 Comments

The standard deviation from a uniform distribution bounded by [0,1] (ie, rand) is usually around 0.083. It will be lower in your example since the values are multiplied by 0.2. I think the OP wants a variance (and std) of 1 which can be done with the randn function.
Sir, I want to add noise in the signal that shown in figure by usnig the above mention values....
Adam Danz. I see. thanks for the advice.
I used a data like yours. you should be fine sir.
use "rand" for uniformly distribution
use "randn" for normal distribution as Adam Danz said.
t = 0:20;
x = zeros(size(t));
% base kW = 100;
x(12:21) = 100*[1 2 3 4 5 6 9 5 3 1];
an = 1; % noise factor
% noise = an*(rand(size(x))-0.5);
noise = 100*an*(randn(size(x)));
stairs(t,x,'r','linewidth',1)
hold on
stairs(t, x+noise)
Thank you Sir...
you're welcome.

Sign in to comment.

More Answers (1)

Adam Danz
Adam Danz on 13 Aug 2020
Edited: Adam Danz on 13 Aug 2020
will return an array of random values from a standard normal distribution with mean=0 and variance=1. The array will be the same size as your signal. However, the max value has a very low probability that it will be greater than ~6. Remember that with standard normal distributions, 99.9% of all values are within +/- 3 from the mean.

Categories

Find more on Networks in Help Center and File Exchange

Products

Release

R2011a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!