Effacer les filtres
Effacer les filtres

Improving the code to change the dimension of the variable.(about the autocorrelation and autocorr)

1 vue (au cours des 30 derniers jours)
I have to write the code like the question said,and here is my code
N=16;
fD_Ts=0.001;
for n = 1:1:100
theta_n(n)=0+(2*pi)*rand(1,1);
phi_n(n)=0+(2*pi)*rand(1,1);
a_n=( (2*pi*n+theta_n)./N )
for m=1:1:1000
h_c=(1/N)*cumsum(cos(2*pi*m*fD_Ts*cos(a_n))+phi_n);
h_s=(1/N)*cumsum(sin(2*pi*m*fD_Ts*cos(a_n))+phi_n);
h_total=h_c+1i*h_s;
answer=autocorr(h_total);
end
end
Before looking the code,we know if we want to plot the (n,autocorrelation),n and autocorrelation have to be the same dimension,that is,1 by 100 matrix.However,i found that the dimension of answer is just 1*21 double,why?how should i improve my code to let the dimension of answer become from 1*21 to 1*100 ?
I don't know how to write the autocorrelation like the formula,if writing that formula is the only way,can anyone teach me how to write that code?Thanks a lot

Réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by