Effacer les filtres
Effacer les filtres

Please someone help me check my code?..Thanks

2 vues (au cours des 30 derniers jours)
Emmanuel
Emmanuel le 28 Mar 2014
Commenté : Image Analyst le 28 Mar 2014
e
for i=1:10000
dW = sqrt(var)*((randn(1,N)));
phi= [0,cumsum(dW)];
phi_t=2*pi*phi;
c_t=exp(j*phi_t);
phi_nTs_cum=phi_t(1:64);
c_t_sampled=exp(j*phi_nTs_cum);
end.
This was what i implemented could you check if i am correct.i just want 64 samples of phi_t every symbol duration after every loop.i am sceptical because i did not use the symbol duration in my code.please help?

Réponse acceptée

Image Analyst
Image Analyst le 28 Mar 2014
Yes, lots of problems. First off, the "e" line will throw an exception if e has not been defined. Next, it's badly indented. Then, the period after the "end" will cause a syntax error. Then you used var in a bad way. Either you previously declared your own var, and didn't show us, thus destroying the built in var() function, or you're calling the built-in var() function with no arguments. Both are very bad.
This looks like some kind of a Monte Carlo experiment where you're running 10,000 experiments generating N random numbers each time. The whole thing could be vectorized and the for loop eliminated just by getting a 2D array of random numbers right at the start. But if you don't, you don't have any indexes on the values you calculate in the loop so they're just being overwritten every time, so what's the point of that? Try phi_t(i) instead of just plain phi_t.
Finally, don't use i (the imaginary variable) as a loop index. Use k or experiment or something else, preferably descriptive, instead of i.
  4 commentaires
Emmanuel
Emmanuel le 28 Mar 2014
This is very helpful.Thanks a million!,by the way var represents the variance of the random Gaussian signal with zero mean.
Image Analyst
Image Analyst le 28 Mar 2014
You're welcome. I didn't know what you wanted j to be. If you want it to be the imaginary variable, assign it to sqrt(-1) instead of 5 like I did, and then you can plot the real and imaginary parts of c_t_sampled separately.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Symbolic Math Toolbox dans Help Center et File Exchange

Tags

Aucun tag saisi pour le moment.

Community Treasure Hunt

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

Start Hunting!

Translated by