# matlab code for autocorrelation function

Status
Not open for further replies.

#### afifar

##### Newbie level 5

if an input is wide-sense stasioner with autocorrelation function is RXX(t)=10e^(-2|t|).

what is matlab code for that function ?

If you are asking the code to compute that Rxx(t) function it is very easy to do that in Matlab:

Code:
% Define range of t in the interval [-1;1] with steps of 0.01
t = [-1:.01:1];
% Compute the function with input vector t (with absolute values)
R = 10 * exp(-2 * abs(t));

If you are asking the code to compute that Rxx(t) function it is very easy to do that in Matlab:

Code:
% Define range of t in the interval [-1;1] with steps of 0.01
t = [-1:.01:1];
% Compute the function with input vector t (with absolute values)
R = 10 * exp(-2 * abs(t));

Is that all ? how can i decide the mean of output ?

Last edited:

Yes, that's all! This is Matlab ;-)

To get the average of a vector (in this case R), just use the following built-in function

Code:
avg = mean(R);

• afifar

Points: 2