- #1
EngWiPy
- 1,368
- 61
Hello,
I have the following piece of code in Mathematica:
Despite the variable "SNR" changed in each iteration of the for loop, the printed result is the same in all iterations. Why is this?
Thanks in advance
I have the following piece of code in Mathematica:
Code:
Na =.;
Q =.;
A = 23;
Q = 15;
Na = 21;
MGF[s_, gC_] := 1/(1 - gC*s);
a[n_] := If[n == 0, 2, 1];
For[SNRdB = 0, SNRdB <= 40, SNRdB = SNRdB + 2, SNR = 10^(SNRdB/10);
gC = 0.5*SNR;
Print[SetPrecision[Pout = ((2^-Q*E^(A/2))/SNR*\!\(
\*UnderoverscriptBox[\(\[Sum]\), \(q = 0\), \(Q\)]Binomial[Q, q]*\(
\*UnderoverscriptBox[\(\[Sum]\), \(n = 0\), \(Na + q\)]
FractionBox[
SuperscriptBox[\((\(-1\))\), \(n\)], \(a[n]\)] Re[
\*FractionBox[\(MGF[\(-
\*FractionBox[\(A + \((2*Pi*I*n)\)\), \(2*SNR\)]\), gC]\),
FractionBox[\(A + \((2*Pi*I*n)\)\), \(2*SNR\)]]]\)\)) + (E^-A/(
1 - E^-A) + (E^(A/2)*2^-Q)/SNR \!\(
\*UnderoverscriptBox[\(\[Sum]\), \(q = 0\), \(Q\)]
\*SuperscriptBox[\((\(-1\))\), \(Na + q + 1\)]*Binomial[Q, q]*Re[
\*FractionBox[\(MGF[\(-
\*FractionBox[\(A + \((2*Pi*I \((Na + q + 1)\))\)\), \(2*SNR\)]\),
gC]\),
FractionBox[\(A + 2*Pi*I \((Na + q + 1)\)\), \(2*SNR\)]]]\)), 10]]]
Despite the variable "SNR" changed in each iteration of the for loop, the printed result is the same in all iterations. Why is this?
Thanks in advance