My stochastic processes program

Hello My teacher Matt
I have a program and When I asked my teacher if my solution is
true or not,he said to me that my solution is not correct
Please,could you help me
My program
N=400; %Define Number of samples((times))
f1=1; % Frequency of the cosinewave
FS=200; % Sampling Frequency
Q=0;
t=1:400;
n=0:N-1;
X1=0;
for i=1:400
for j=1:301
X=cos((2*pi*f1*(n/FS))+Q);
X1=X1+X;
Q= -2*pi/N;
end
Q=Q*2;
end
subplot(2,1,1); % Prepare the figure
plot(t,X1/(400*301)) % Plot mean value vs. t
grid;
title('mean value function of cosinewave ');
xlabel('Time index');
ylabel('Mean value');
Rxx=xcorr(X1); % Estimate its autocorrelation
subplot(2,1,2);
plot(Rxx); % Plot the autocorrelation
grid;
title('Autocorrelation function of the cosinewave');
xlabel('Time index');
ylabel('Autocorrelation');
My teacher at university said to me that I have mistake here and
he wrote this note but I did not understand what he mean!!!
X=cos((2*pi*f1*(n/FS))+Q); % Generate x(t)
Here X must be as X(i,j). Then it has 400 rows and 301 columns. Row number equals to the number of realizations

1 comentario

Oleg Komarov
Oleg Komarov el 30 de Mayo de 2011
Can you please format the code properly: http://www.mathworks.com/matlabcentral/answers/7885-tutorial-how-to-format-your-question

Iniciar sesión para comentar.

Respuestas (1)

Oleg Komarov
Oleg Komarov el 30 de Mayo de 2011

0 votos

You basically calculate the same X all the time. Nothing changes inside the loops.

4 comentarios

reem
reem el 30 de Mayo de 2011
The theta Q is changed because I multiply it every time by 2 number
Oleg Komarov
Oleg Komarov el 30 de Mayo de 2011
Yes, by the same numbers, which means that it doesn't change.
reem
reem el 30 de Mayo de 2011
Yes,you are true
so I must apply that,isn't it???
Q1=Q1+Q
Oleg Komarov
Oleg Komarov el 30 de Mayo de 2011
Maybe, I don't know what is the stochastic process you have to reproduce.
Also, you probably have to change one of the input of X according to the indices i and j but the only vector you have in the expression is n (1 by 400) so you can use n(i), but this leaves the j index unused.

Iniciar sesión para comentar.

Categorías

Más información sobre Performance and Memory en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 30 de Mayo de 2011

Community Treasure Hunt

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

Start Hunting!

Translated by