representing the correlation function

2 views (last 30 days)
Mosanu Cristina Alina
Mosanu Cristina Alina on 7 Jan 2022
Commented: Jon on 7 Jan 2022
The discrete signal is disturbed by a random noise. To calculate the autocorrelation of the disturbed signal, I wrote the code:
n=0:27;
x=sin(pi*(1/7)*n);
w=randn(1,length(x)); % noise
y=x+w;
[r,lag]=xcorr(y,y);
stem(lag,r)
But I'm not sure if the noise parameters are well chosen.

Answers (1)

Jon
Jon on 7 Jan 2022
In your code the sin wave signal will have an amplitude of one, and the stadard deviation of the noise signal will also be one.
If you want a different signal to noise ratio, you can scale the noise signal, for example to have a standard deviation of 0.1 you could use
w= 0.1*randn(1,length(x)); % noise
By the way, to get your code formatted nicely and to make it easy for others to cut and paste it you can use the code button on the MATLAB answers toolbar
  2 Comments
Mosanu Cristina Alina
Mosanu Cristina Alina on 7 Jan 2022
but what I don't understand is, at the noise, what parameters can I take? And the disturbed signal is given by the sum of the initial signal and the noise?
Jon
Jon on 7 Jan 2022
I'm not really understanding what your questions mean. Could you please try to explain further. What is it that you are actually trying to do.
In case it helps here's a couple of points that I think may relate to what you are asking.
There are many ways to model noisy signals. The appropriate noise model, depends upon the physics of the application. Without assuming any specific details, one of the simplest is to consider the signal to be a linear sum of the original signal and some "additive" noise. So as in you above script, you create a noise signal w using a noise signal w and add it to the original signal using:
y=x+w;
Regarding the noise signal, in the absence of any further knowledge of the spectrum or characteristics of the noise a simple model is to just consider it as samples from a gaussian (normally distribution) characterized by a wbar and standard deviation sd, so you could use
sd = 0.1 % or whatever value you choose for the standard deviation
wbar = 0.3 % or whatever value you choose for the mean value
w = wbar + sd*randn(1,length(x))
In your original code, you have implicitly chosen sd = 1 and wbar = 0.

Sign in to comment.

Products


Release

R2013b

Community Treasure Hunt

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

Start Hunting!