Matlab DCMC capacity

This Matlab code calculates the Discrete-input Continuous-output Memoryless Channel (DCMC) capacity of AWGN and uncorrelated Rayleigh fading channels for BPSK, QPSK, 8PSK and 16QAM.

AWGN SNR
Rayleigh SNR
AWGN Eb/N0
Rayleigh Eb/N0

Copyright © 2008 Robert G. Maunder. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

235 Responses to “Matlab DCMC capacity”

  1. farag Says:

    capacity channel

  2. Asimg Says:

    I found this helpful

  3. Pir Ahmed Says:

    Hi Rob, just wanted to ask you that where did you get this probability formaula to calculate the channel capacity.

    The classic shannonian formula is different. Can you please give me the link to the research paper.

    Thankyou
    King Regards

  4. Rob Says:

    Hi Pir,

    Shannon’s formula assumes a Gaussian distributed input into the channel and can be referred to as the Continuous-input Continuous-output Memoryless Channel (CCMC) capacity. The simulation here gives the Discrete-input Continuous-output Memoryless Channel (DCMC) capacity, which considers the effect of having a digital modulation scheme, such as M=2-PSK or M=16-QAM. The main effect of this is that the number of bits per channel use (or bits/s/Hz) that can be achieved is limited by log2(M), even when the channel SNR is very high. You can find out more about this in…

    L. Hanzo, S. X. Ng, T. Keller and W. Webb, “Quadrature Amplitude Modulation,” Wiley, Chichester, UK, 2004.

    Hope this helps, Rob.

  5. yin Says:

    Hi, Rob

    I’m not sure about the capacity formula used in your m-file. I wondered why there is no Rayleigh pdf factor in the integrand of

    mean(sum(probabilities.*log2(probabilities)))

    Maybe i misunderstand it. Would u please give some details?

    Thanks
    Regards

  6. Rob Says:

    Hi Yin,

    The Rayleigh fading is considered by the demodulator on the line…
    probabilities = max(exp(-(abs(ones(length(modulation),1)*rx - modulation.’*channel).^2)/N0),realmin);
    This calculates a probability for each of the constellation points. The capacity is then calculated by subtracting the entropy implied by the probabilities from the number of bits per symbol.

    Hope this helps, Rob.

  7. Caste Says:

    Hello Rob,

    I check your post very useful, could you give a hint of how to plot those graphs you show in your post?

    Thanks

  8. Rob Says:

    Hi Caste,

    You need to use a vector of SNR values and a for loop that records the corresponding capacity values into a vector.

    You can plot the SNR plots using
    plot(SNR,capacity)

    You can plot the Eb/N0 plots using
    plot(SNR-10*log10(capacity),capacity)

    Take care, Rob.

  9. Ideal Says:

    Dear Rob,

    I think you define Eb/N0 = 1/sigma^2 for QPSK and Eb/N0 = 1/2*sigma^2 for BPSK? AM I right?

  10. Rob Says:

    Hi Ideal,

    Actually, I use N0 = 2*sigma^2 regardless of the situation, where the real and the imaginary part of the noise each have a standard deviation of sigma. For BPSK, it is possible to use purely real-valued noise and N0 = sigma^2, however this unfairly downgrades the performance of BPSK relative to QPSK.

    Note that Es/N0 = 10*log10(1/(2*sigma^2)) and Eb/N0 = Es/N0 - 10*log10(R*log2(M), where R is the coding rate of the channel code and M is the number of constellation points used by the modulator.

    Take care, Rob.

  11. Caste Says:

    Hello Rob:

    Thanks for your answer, actually computing DCMC capacity in Matlab is much more easier than other language, I was trying to do it in C, but the complexity increases.
    Congratulations for your blog and thanks for sharing the information with everybody.

  12. Rob Says:

    You’re welcome :-)

  13. Caste Says:

    Hello Rob:

    Thanks for your answer, actually computing DCMC capacity in Matlab is much more easier than other language, I tried to plot the graphs described above however I couldnt success,the capacity value decreases after 2 dB for 16QAM almost to cero bits/symbol, here is the coded maybe you can give me a hand to check it. Thanks so much one more time…

  14. Caste Says:

    Hi Rob:

    This is the last version of my attemp to figure it out your graphs, this time I am trying to save it into an *.txt file so I can plot it using other software, however I couldn’t success in the operation, what could it be wrong?, I really appreciate your help.

  15. Rob Says:

    Hi Caste,

    I’ve put a version of the code that can be used to plot the figures shown above at…
    http://users.ecs.soton.ac.uk/rm/wp-content/capacity2.m

    Take care, Rob.

  16. Ideal Says:

    Hi Rob,

    Can you please tell me, the performance difference of QPAK and 4-QAM in calculating the capacity curve? I mean is the curve will be different if we change the constellation point shape to 4-QAM. i.e.
    qam = sqrt(1/2)*[+1+1i, -1+1i, -1 - 1i, 1 -1i].
    even then we can use the same program you wrote?
    my way of normalizing 4-qam is right? please answer thanks

  17. Rob Says:

    Hello Ideal,

    The capacity of QPSK and 4QAM is the same, since one is just a rotation of the other. The constellation points you have provided look correct to me and should be fine to use in this Matlab code.

    Take care, Rob.

  18. Caste Says:

    Hello Rob,

    I have one question, how can we calculate Non-Ergodic capacity for MPSK constellations?, as you know ergodic capacity mantains a constant bit-rate for a period of time, which can be inferred from the graphs, after a period of time the bit-rate is constant for every constellation size. Thanks for your answer

  19. Rob Says:

    Hi Caste,

    You can use the outage probability to characterise a non-ergodic channel. This quantifies the fraction of time for which your scheme’s bit rate is exceeded by the channel’s capacity, as it varies with time.

    Take care, Rob.

  20. Caste Says:

    Hello Rob,

    I am working exactly with outage probability for rate distortion analysis, my analysis is on MPSK constellations. In my analysis I need to calculate SNR values for different links (cooperative relay), so assuming a Rc=0.85 for example will permit me to obtain an average SNR value from your plots (for every MPSK constellation size) in specific fraction on time, do you think that this assumption make sense? Thanks for your answer.

    Take Care, Caste

  21. Rob Says:

    Hi Caste,

    This sounds reasonable to me - you can measure the fraction of time that the SNR is less than the value obtained from the capacity plot.

    Take care, Rob.

  22. Rob Says:

    By the way, the CCMC capacity plots for the AWGN and Rayleigh fading channels are given by equations 2 and 4 in…
    http://eprints.ecs.soton.ac.uk/20942/

    You can draw the AWGN SNR plot using these Matlab commands…
    snr_dB = -10:20;
    snr = 10.^(snr_dB/10);
    C = log2(1+snr);
    plot(snr_dB,C);

    You can draw the Rayleigh fading channel SNR plot using these Matlab commands…
    snr_dB = -20:30;
    snr = 10.^(snr_dB/10);
    C = exp(1./snr).*expint(1./snr)/log(2);
    plot(snr_dB,C);

    You can draw the AWGN Eb/N0 plot using these Matlab commands…
    snr_dB = -20:18;
    snr = 10.^(snr_dB/10);
    C = log2(1+snr);
    plot(snr_dB-10*log10(C),C);

    You can draw the Rayleigh fading channel Eb/N0 plot using these Matlab commands…
    snr_dB = -20:30;
    snr = 10.^(snr_dB/10);
    C = exp(1./snr).*expint(1./snr)/log(2);
    plot(snr_dB-10*log10(C),C);

  23. Ideal Says:

    What if I want to plot 32-QAM and 64-QAM and 128-QAM capacity using your code?
    what can be points?

  24. Rob Says:

    Hello Ideal,

    Assuming that you have the Communications toolkit for Matlab, you can obtain the constellation points using these commands…

    M=32 % or 64, or 128, etc
    mod = modem.qammod(M)
    modulation = mod.Constellation/sqrt(mean(abs(mod.Constellation).^2))

    Take care, Rob.

  25. Ideal Says:

    Hi Rob,

    thanks for your responses. One more question.
    if we increase the number of symbol, is it affects the symbol energy? like if we increase the symbol (2 symbols per time frame), is the symbol energy reduced by a factor of 1/4, I mean is there any relationship between the number of symbols and symbol energy? Thanks

  26. Rob Says:

    Hi Ideal,

    It does affect the symbol energy. However, dividing by sqrt(mean(abs(mod.Constellation).^2)) normalises the constellation diagram, so that the average transmission energy is 1, regardless of how many constellation points there are.

    Take care, Rob.

  27. Ideal Says:

    Dear Rob,

    thanks for the quick response. just one question, what is the difference between the M-PSK and M-QAM capacity curves? are they have same shape or different depending on SNR. please also give me any reference if possible.
    I was thinking that the capacity curve for 16-QAM will be different due to its squared shape constellation than simple QPSK or 8-PSK. Thanks

  28. Rob Says:

    Hi Ideal,

    In general, different arrangements of constellation points gives a different capacity curve. Some arrangements are better than others, yielding higher capacities. There is a book that explains the DCMC capacity in greater detail. You can download a sample of some of its chapters from…
    http://www-mobile.ecs.soton.ac.uk/newcomms/files/u1/QAM3-chaps_1-22-24.pdf

    Take care, Rob.

  29. sana Says:

    HI ALL

    Can any one help me with Adaptive Modulation Code for Ergodic Capacity

    Thanks

  30. Con Says:

    HI Rob,

    THANKS for your code. It is really helpfull. I’m trying to understand how did you reach to the capacity equation.
    I was wondering if you know where to find chapter 23 of the book you are refering to (Quadrature Amplitude Modulation).

    Thanks again.
    Con

  31. Rob Says:

    Hi Con,

    I’m afraid that chapter is only available in the book - perhaps your library has a copy…

    Take care, Rob.

  32. Con Says:

    Hi again Rob!

    Thanks. Your matlab implementation is very elegant!
    I\’m trying to reach your equation for channel capacity.

    The first part is quite clear assuming Uniform distrubition for X.
    But the second part of your capacity is the tricky one:

    Capacity can be defined after some calculations as http://imageshack.us/photo/my-images/20/capacitydiscreteinput.png/

    Because the simulation is ergodic the integral over Y can be done with the mean.
    Then, you are calculating the probabilites of the symbol p(y/x), but in your final equation I\’m still missing the 1/abs(X) and the denominator. of the log2.

    I also try to reach your elegant solution with the reference of L. Hanzo, Chapter 23. But from equation 23.23 I\’m not able to go beyond that.
    http://imageshack.us/photo/my-images/830/equation2323.png/

    Thanks again :)
    Con

  33. Rob Says:

    Hi Con,

    In my code, ‘probabilities’ is calculating the probability of each transmitted symbol having each possible value. Then sum(probabilities.*log2(probabilities)) is calculating the entropy of each symbol (but multiplied by -1). Then the capacity is calculated as the number of bits per symbol minus the average entropy of the symbols.

    This explanation is equivalent to both the equations you have provided, particularly equation 23.23.

    Take care, Rob.

  34. zhiven Says:

    Hi Rob

    Thanks for all your replies, though I am not exactly working on them but I am trying to plot exit charts so in that sense your posts are realy helpful.

    By the way, I wanted to know about combining of LLRs, as how should I combine the two LLR sequence.

    And is combining of simple bit sequence similar to combining of two LLR sequence

  35. Rob Says:

    Hi Zhiven,

    You can combine two sets of LLRs by simply adding them, provided that they both pertain to the same set of bits.

    By contrast, when you have two sets of LLRs that each pertain to a different set of bits, you have to do things differently. If those bits are combined using XOR operations, then the LLRs should be combined using boxplus operations. The boxplus operator is defined in…
    http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.142.291&rep=rep1&type=pdf

    Take care, Rob.

  36. Caste Says:

    Hello Rob:

    Thanks for your answers so far,

    I have one question regarding OUTAGE CAPACITY for MPSK constellation, can you please give me a hint regarding how can we calculate this outage pagacity for each MPSK constellation, as far as I know , outage event occurs when the SNR at the RX, falls below a threshold SNRmin , so we can’t use the classical approximation of C(out)=log(1+SNRmin), is it possible somehow to use the curves from your post?

    Thanks for your answer

    Best Regards

  37. Rob Says:

    Hello Caste,

    You can use the curves from this post to convert from your transmission rate (in bits per symbol or bits per second per Hz) to the minimum required SNR. You can then calculate the outage capacity by determining the probability that the SNR will exceed this minimum required value. In an AWGN channel, the SNR does not vary and so this probability will be either 0 or 1. In a Rayleigh fading channel, the instantaneous SNR varies with the fading and so the probability will be somewhere between 0 and 1.

    Take care, Rob.

  38. Caste Says:

    Hello Rob,

    Thanks for your answer, what you mean is to select a minimum required SNR based on the BER for each constellation, for example in BPSK, for a BER=10e-3, the minimum required SNR will be 6,68dB, then according to your recommendations, Cout is the probability that the SNR exceed 6.68dB?, if so how can i do this?

    Thanks again for your answer

    Best Regards

    Caste

  39. Caste Says:

    Hi again Rob,

    Please let me explain myself in a better way:

    I want to compute end-to-end distortion following the classical expression for gaussian sources: D=2*exp(-2*Cout)*(1-Pout)+Pout, for MSK.

    Assuming Rayleigh fading Pout is express as: Pout=1-exp((minSNR)/(Eb/N0)), and then: minSNR=-Eb/N0*ln(1-Pout), so selecting a especific BER for every MPSK constellation ( for example 10e-2), I can obtain Eb/N0 for every M=2,4,8,etc, then I have a equation that express minSNR as a function of Pout for every MPSK constellation size.

    The remaining part would be to make some analysis that will permit to express this Cout as a function of this minSNR, at the end I would like to have an expression that permits to express distortio D, as a funtion of Pout (considering already the effect of MPSK constellation sizes).

    Cout is defined as the reliable rate at a certain outage probabilty, so we can define Pout=1-P(SNR>minSNR), so in this point I am lost in the darkness.. :(, is this Cout going to be a fixed value in the capacity curves of MPSK constellation sizes?.

    Thanks for your help.

    Best Regards

    Caste

  40. Rob Says:

    Hmmm,

    To calculate outage capacity, you should be using a capacity plot, not a BER plot. The way you calculate the outage probability depends on the characteristics of the channel. In a Rayleigh fading channel, you can perform an integration on a function of the Rayleigh PDF to determine the probability that the SNR will exceed a particular value.

    Take care, Rob.

  41. Caste Says:

    Hello Rob:

    Actually the reason why at the begining i want to use BER is to calculate the minimum SNR required, otherwise how can i set the minimum point of operation? Can u please give me an example?

    Thanks for your answer

    Best regards

  42. Rob Says:

    Hi Caste,

    Your approach seems reasonable and more accurate than considering only the capacity. However, I would call it “outage probability”, rather than “outage capacity”, since you are not using the capacity plots in your approach.

    To use the capacity plots, you would draw a horizontal line in the plot at the position along the y axis that matches the number of bits per channel use in your scheme. The minimum SNR is then the position along the x axis where the horizontal line crosses the capacity plot.

    Take care, Rob.

  43. Rajab Says:

    Hi Rob
    Can I use the following capacity equation to plot the throughput:
    C = log2(M) * ( 1 - H(p)).
    where H(p) = - p*log2(p) - (1-p)*log2(1-p)
    where p is the bit error rate not the symbol error rate.
    is the equation correct??????????

    thanks in advance

  44. Rob Says:

    Hi Rajab,

    I’m not in my office at the moment so I can’t check, but I think your equation would only work for a Binary Symmetric Channel (BSC), which has a discrete input and discrete output. This won’t work in general, such as for an Additive White Gaussian Noise (AWGN) channel, which has a discrete input and a continuous output.

    Take care, Rob.

  45. john shin Says:

    hi, rob.
    thanks for your m-code. It is pretty helpful to understand the capacity.

    I have a question.
    I\\\’d like to know the capacity in frequency selective channel such as sqrt(3)*[1 1 1].
    As i know, the capacity in frequency selective channel depends on H(f)^2/N0.
    I tried to draw the capacity by modifying your m-code. but I got un-expected results, which under around 5 snr dB, its capacity exceeds the awgn capacity.

    please give me a tip to draw the capacity correctly.

    best regeards.

  46. Rob Says:

    Hello John Shin,

    I’m afraid that I’ve never drawn the capacity for frequency selective channels and I can’t offer any tips for this…

    There seems to be some good references on this topic at Google Scholar…
    http://scholar.google.co.uk/scholar?q=frequency+selective+capacity&hl=en&btnG=Search&as_sdt=1%2C5

    Take care, Rob.

  47. john Says:

    hello rob.

    thanks for your quick response and good references.

    Best Regards,
    John.

  48. Pooja Says:

    Hi,

    Can you help me with any formula or code to plot throughput v/s SNR plot for MIMO system??

  49. Rob Says:

    Hi Pooja,

    I’m afraid that I don’t have any code for plotting the DCMC capacity of MIMO channels. However, it is not too difficult to do this by combining all the received soft information together and using it to determine the probability of transmitting each possible combination of signals from the various antennas. You can then use similar equations to those in my code.

    Take care, Rob.

  50. Pooja Says:

    Hi Rob,

    Thanks for reply… Will try to derive the similar formulas for MIMO systems too…

    Have a great day,
    Regards,
    Pooja.

  51. anand Says:

    hi sir i want to optimize MIMOCapacity(R_t, R_r, SNR)
    fitness=c=log(det(I+pQ/Nt) but problem plz help me matlab code

  52. Rob Says:

    Hello Anand,

    I’m afraid that I don’t have any Matlab code for the MIMO channel capacity.

    Take care, Rob.

  53. Anand Says:

    ok,actually i want to optimize mimo ofdm ergodic capacity through Genetic Algorithm but my result is not iterative iso plz help me

  54. Rob Says:

    Hello Anand,

    I’m afraid that I don’t have any Matlab code for the channel capacity of OFDM either…

    Take care, Rob.

  55. fateme Says:

    hi every body…can anyone plz guide me how to plot outage probability vs SNR?

  56. Rob Says:

    Hello Fateme,

    You can use the curves from this post to convert from your transmission rate (in bits per symbol or bits per second per Hz) to the minimum required SNR. You can then calculate the outage capacity by determining the probability that the SNR will exceed this minimum required value. In an AWGN channel, the SNR does not vary and so this probability will be either 0 or 1. In a Rayleigh fading channel, the instantaneous SNR varies with the fading and so the probability will be somewhere between 0 and 1.

    Take care, Rob.

  57. imran Says:

    i need a theoretical formula of Bit Error Rate or Symbol error rate for 16-APSK (amplitude phase shift keying). i got the simulation result . but i dont know the exact theoretical formula or equation regarding of this problem. Plz Help me by giving me the theoretical equation or formula of Bit Error Rate or Symbol Error Rate if anybody knows.

  58. Rob Says:

    Hi Imran,

    There are lots of these derivations in…
    Quadrature Amplitude Modulation: From Basics to Adaptive Trellis-Coded, Turbo-Equalised and Space-Time Coded OFDM, CDMA and MC-CDMA Systems, 3rd Edition, by L. Hanzo, S. X. Ng, T. Keller, W. T Webb.

    You can download some of the chapters from this book at…
    http://www-mobile.ecs.soton.ac.uk/newcomms/files/u1/QAM3-chaps_1-22-24.pdf

    Take care, Rob.

  59. Imran Says:

    theory SER_16PSK = erfc(sqrt(10.^(Es_N0_dB/10))*sin(pi/M));
    theorySER_16QAM = 3/2*erfc(sqrt(0.1*(10.^(Es_N0_dB/10))));

    like this how can or what will be the theoretical formula for 16-APSK.
    Plz Rob if you know then help me.

    i read your given link,
    i am confused Adaptive PSK Modulation Schemes i.e is it APSK but i know APSK means Amplitude Phase shift keying.
    in 16 APSK, 2 concentric ring, like inner is 4 and outer is 12.
    but in 16-PSK, only one circle.
    if you have any suggestion please inform me. i am waiting for your kind response.
    take care
    imran

  60. Rob Says:

    Hi Imran,

    The constellation you are describing is similar to star-16QAM, which has 8 points in an inner ring and 8 in an outer ring. If you can find the derivation of the BER for this, you should be able to adapt it for your constellation. I’m afraid that I have never looked for these derivations before, but I suspect that they can be found.

    Take care, Rob.

  61. deen Says:

    Hi,

    Thank you very much. Can you explain why you use

    mean(sum(probabilities.*log2(probabilities))) in the code? because the probabilities is normalise as probabilities = probabilities ./ (ones(length(modulation),1)*sum(probabilities));

    I try to modify your code to compute the BICM capacity, and then have some problems in the above confusion.

    Thank you very much.

  62. Rob Says:

    Hello Deen,

    That line is calculating the average entropy of the probabilities. This a different calculation to the one used to normalise the probabilities.

    Take care, Rob.

  63. Nyakec Says:

    Wonderful work, Rob.
    How do we derive bit likelihood ratios for 4QAM,16QAM and 64QAM to use in a code. By the way, in your statement below: R, is it the coderate or the bitrate ? Say polar code (512,128), r=1/3. Is this equal to R or is R=0.5 like the bit rate of polar codes!

    Note that Es/N0 = 10*log10(1/(2*sigma^2)) and Eb/N0 = Es/N0 - 10*log10(R*log2(M), where R is the coding rate of the channel code and M is the number of constellation points used by the modulator.

    Thanks

  64. Nyakec Says:

    Sorry, r =0.25

  65. Rob Says:

    Hi Nyakac,

    I have some Matlab code for deriving the LLRs of various different modulation schemes. You can see some discussion about this and download the code at…
    http://users.ecs.soton.ac.uk/rm/resources/matlabexit/#comment-1545

    R is the ratio of input bits to output bits, so that R*log2(M) is the ratio of input bits to transmitted symbols.

    Take care, Rob.

  66. Nyakec Says:

    Thanks Rob,
    I take that comment to mean the input/output to the encoder. We had an argument with a colleague and I hope this adds insight to our understanding.
    Great!
    Rgds

  67. Nyakec Says:

    Any code for Chase algorithm? or Kaneko, or list, I would be happy.
    Kind regards,

  68. Rob Says:

    Hi Nyakec,

    I’m afraid that I don’t have any code for those algorithms…

    Take care, Rob.

  69. jai Says:

    hi rob dis is jai thanks for ur mcode.iam doing project on cooperative diversity in wireless networks.In that iam doing comparison of snr in amplify and forward relay and decode and forward relay networks do u hav any matlab code for that.

  70. Rob Says:

    Hi Jai,

    I’m afraid that I don’t have any matlab code for cooperative diversity schemes.

    Take care, Rob.

  71. Anne Na Says:

    Hi Rob,

    I have a bit confusion, in capacity eq. 23.23, the capacity is calculated as the number of bits per symbol minus the average entropy of the symbols. Then, why in your matlab command, you used ‘+’?

    channel_capacity(index) = log2(length(modulation))+mean(sum(probabilities.*log2(probabilities)));

    In your previous comment, you did mention that ” sum(probabilities.*log2(probabilities)) is calculating the entropy of each symbol (but multiplied by -1).”
    Why do you choose to multiply with -1? Any reason behind that?

  72. Rob Says:

    Hello Anne,

    This is because I am using log2(probabilities), rather than log2(1./probabilities). This is okay because log2(probabilities) = -log2(1./probabilities).

    Take care, Rob.

  73. Ideal Says:

    Dear Rob,

    I have question about the mutual information (MI) calculations.
    In you matlab script, you use the following model,
    y = x + sigma*n, where sigma = sqrt(N0/2), N0 = 1/SNR_Linear; x = symbol

    I want to use the following model, y = sqrt(Es)*x + n, where n = zero mean, unit variance noise, and Es is the received symbol energy, Es/No = (P/No*R), where P is the transmit power and R is the symbol rate.

    I was thinking that the MI plot should be same in both of the two model? Am I wrong somehwere? please give me some suggestion. Thanks

  74. Rob Says:

    Hi Ideal,

    I would expect the MI plot to be the same for both y=sqrt(Es)*x+n and y=x+sigma*n. I think that you are getting confused by the difference between Es/N0 and Eb/N0…

    Es/N0 = SNR
    Eb/N0 = SNR - 10*log10(bits_per_transmission)

    Here, Es/N0, Eb/N0 and SNR are all expressed in dB. bits_per_transmission is a function of R.

    Take care, Rob.

  75. Ideal Says:

    Thanks.

    Let me explain in other way, i.e., y = sqrt(P)*x + n, where I consider the BPSK system. Now SNR = Es/N0 = Eb/N0. In above equation P is the received signal power, x belongs to (+1,-1) and n~(0,1). What is the relationship of SNR and P in this case. I think SNR = sqrt(P) but what will be the relationship of SNR or P with the transmit signal power.

    Like in case of y = x + sigma*n, it is easy to say that sigma = sqrt(1/2*SNR), but I am still confuse with the above system. Like how to simulate it? Or I can just simulate by saying that y = sqrt(SNR)*x + n and SNR = sqrt(P) and vary P from 0 to 10 dBm. Please Please clear my this concept. Thanks

  76. Rob Says:

    Hi Ideal,

    In the case of y = sqrt(P)*x + n, the SNR will be equal to P, not to sqrt(P)…

    Take care, Rob.

  77. Ideal Says:

    Yes,
    SNR = P, It was mistakenly written. I am using your script DCMC capacity

    But with that the (the script written by you) DCMC capacity results doesn’t match of both models.
    1. y = x + n, n~(0,sigma), sigma = sqrt(N0/2), N0 = 1/SNR_Linear
    probabilities = max(exp(-(abs(ones(length(modulation),1)*rx - modulation.’*channel).^2)/N0),realmin);

    2. y = sqrt(SNR)*x + n, n~(0,1), SNR = P_Linear, N0 = 2*sigma^2, sigma^2 = 1,
    probabilities = max(exp(-(abs(ones(length(modulation),1)*rx - modulation.’*channel).^2)/2),realmin);

    Both models give me different results, why, or where I am wrong. Please can you rectify me. Thanks

  78. Ideal Says:

    Dear Rob,

    I got it, I also need to multiply with sqrt(P), i.e.
    p(y|x = sqrt(Es)) = 1/sqrt(2*pi)*exp(rx - sqrt(Es)*x*h), so

    probabilities = max(exp(-(abs(ones(length(modulation),1)*rx - modulation.’*channel).^2)/2),realmin);

    is not correct. The correct one is,

    probabilities = max(exp(-(abs(ones(length(modulation),1)*rx - sqrt(P)*modulation.’*channel).^2)/2),realmin);

    and P = SNR, Thanks for your useful suggestions.

  79. Ideal Says:

    Dear Rob,

    The above method works but I got 3dB difference between the capacity curves. Where I am wrong now? sorry for asking so many times the fundamental questions :(

  80. Rob Says:

    Hi Ideal,

    I’m afraid that I’m not sure what else could be going wrong. It seems that you are getting very close - perhaps with a little more time on this, you will figure it out…

    Take care, Rob.

  81. Ideal Says:

    Dear Rob

    Thanks just let me know Is the below formula correct?

    y = sqrt(P)*x + n; n=randn(0,symbol_count), P = SNR; x = (+1,-1),

    probabilities = max(exp(-(abs(ones(length(modulation),1)*rx - sqrt(P)*modulation.’*channel).^2)/2),realmin);

    Thanks

  82. Ideal Says:

    Dear Rob,

    Thanks I got it now but not sure correct?,
    y = sqrt(P)*tx + n; n~(0,1), P=SNR, tx=modulation(symbols), as you defined for each constellation size in you script.

    I got the same capacity curves when I divide the modulation with sqrt(1/2),
    otherwise I got 3dB in each curves. This division of sqrt(1/2) applies for every constellations BPSK to higher size, 16-QAM.

    Can you please advise me any helpful comments? Thanks

  83. Rob Says:

    Hi Ideal,

    I think that your noise should be generated as follows…

    n = sqrt(1/2)*(randn(1,symbol_count)+1i*randn(1,symbol_count))

    Take care, Rob.

  84. Ideal Says:

    Dear Rob,

    I tried to generate the noise like as you said but it dosn’t match, It only matches if I divide the modulation by sqrt(1/2), i.e., modulation = [+1, -1]/sqrt(1/2); and it applies for all modulations.

    Secondly why should I need to generate the noise with variance sqrt(1/2) because I said the noise is zero mean and unit variance in the 2nd model.

    I am not clear yet but the capacity curves of both models match well with additional term sqrt(1/2). :(

  85. Rob Says:

    Hi Ideal,

    That sqrt(1/2) is needed to maintain a variance of one when using complex noise. This is because complex noise has two dimensions…

    Take care, Rob.

  86. Ideal Says:

    Yes That’s right, now it makes sense,
    N0 = 1;
    n = sqrt(1/2)*(randn(1,symbol_count)+1i*randn(1,symbol_count));

    probabilities = max(exp(-(abs(ones(length(modulation),1)*rx - sqrt(P)*modulation.’*channel).^2)/N0),realmin);

    Now by using the above three lines in your script, the capacity results of both models match very well without the division factor of sqrt(1/2). I think now its right?

  87. Rob Says:

    Hi Ideal,

    It sounds like you have got it now.

    Take care, Rob.

  88. Ideal Says:

    Dear Rob,
    I have some basic question please.
    The receive signal is represented by y = Px + n
    where x is transmitted symbol, P is the transmit power, n is 0 mean 1 variance noise.
    then the SNR = P (transmit power) for BPSK? or not

    I am confuse here and also is there any effect on SNR for higher modulation level.
    please can you clarify my concept please. Also if you can refer some tutorial example will be good. thanks

  89. Rob Says:

    Hi Ideal,

    SNR = P for BPSK, provided that you are using +1 and -1 as your BPSK symbols. For higher order modulation schemes, you need to make sure that mean(constellation_points.^2) has a value of 1. I’m afraid that I can’t think of a tutorial that discusses this…

    Take care, Rob.

  90. Ideal Says:

    Dear Rob,

    Thanks, it means for higher order constellation points, we can consider the unity constraints constellation, e.g. for QPSK, constellation_point.*sqrt(1/2) and SNR in that case will remain same which is SNR = P (transmit power).
    Am I right?

  91. Rob Says:

    Hi Ideal,

    That’s right.

    Take care, Rob.

  92. Rajab Says:

    Helloo Rob

    Is there any formula to convert Bit Error Rate to Capacity, for any M-ary?
    Another question,
    how can I use you code to calculate the end-to-end capacity for two-hops relay for the following case:
    source send symbol, then the relay hard-estimates the symbol and broadcasts it to the destination.?

    My best regards
    Rajab

  93. Rob Says:

    Hi Rajab,

    I’m afraid that I don’t know of any formula to convert BER to capacity. I think that in a two-hop relay scenario, the end to end capacity is just the minimum of the capacities of the two hops…

    Take care, Rob.

  94. Rajab Says:

    Hi Rob

    Actually, using the minimum of the two capacity will not work in my two-hop relaying scheme. Because, in my scheme, the relay hard-estimates the transmitted symbols from the source, and then forward the estimated symbol to the destination. In other words, the relay do not do any channel decoding.

    Assuming the link of the first hop is too bad. so we will have a lot of symbol error at the relay after hard-estimation. So, in this case, the channel decoding at the destination is equivalent to hard decoding, since we lost much information because the hard-estimation.

    thanks for response

    My best regards

  95. Rob Says:

    Hi Rajab,

    Something that you should note is that capacity is a measure of the upper-limit performance that can be potentially achieved in practice. So even though your relay may be forwarding erroneous information, this does not reduce the capacity. All it means is that your scheme is sub-optimal and that its performance is somewhere away from the capacity.

    Take care, Rob.

  96. Rajab Says:

    Hi Rob

    Thanks you for this information.

    My best regards

  97. Rajab Says:

    Hi Rob

    I have a quick question.
    How can I calculate the Mutual information (MI) for discrete input discrete output channel in general? In other words, I want calculate the MI using the data for the input and output using matlab?

    Thanks
    Rajab

  98. Rob Says:

    Hi Rajab,

    A general way to calculate the MI is to express your received bits using LLRs and then to provide them to one of my functions for measuring MI.

    LLR = ln(P1/P0), where P1 is the probability that the bit has a value of 1 and P0 is the probability that the bit is 0.

    Take care, Rob.

  99. Rajab Says:

    Hi Rob

    Could explain this method?

    My best regards
    Rajab

  100. Rob Says:

    Hi Rajab,

    In a binary symmetric channel, where we transmit x and receive y, the LLRs can be calculated as follows.

    In cases where y = 0, the LLRs are given by
    LLR = ln(P(y=0|x=1)/P(y=0|x=0)) = ln(Pe/(1-Pe))

    In cases where y = 1, the LLRs are given by
    LLR = ln(P(y=1|x=1)/P(y=1|x=0)) = ln((1-Pe)/Pe)

    Here, Pe is the probability of transmission error.

    Take care, Rob.

  101. Rajab Says:

    Hi Rob

    But how can I calculate the MI from LLR?.
    Which equation i have to use?

    Thanks for your help

    My best regards

    Rajab

  102. Rob Says:

    Hi Rajab,

    You can use the equation immediately below figure 4 in…
    http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.142.291&rep=rep1&type=pdf

    This equation is implemented in my Matlab function measure_MI_averaging, which you can download from…
    http://users.ecs.soton.ac.uk/rm/resources/matlabexit/

    Take care, Rob.

  103. Rajab Says:

    Hi Rob

    It woks perfectly.
    Thanks for you help

    Rajab

  104. Fourat Says:

    Hi Rob,

    do you have or know any good publication that analyses capacity of DCMC with fading,?

    Thanks

    Fourat

  105. Rob Says:

    Hi Fourat,

    I can recommend the following paper on this…
    http://www-mobile.ecs.soton.ac.uk/sxn99r/paper/capacity-vt06.pdf

    Take care, Rob.

  106. Mfon Says:

    Can you simulate this paper for me:

    On the Area Spectral Efficiency Improvement of
    Heterogeneous Network by Exploiting the
    Integration of Macro-Femto Cellular Networks

    I want to know how they got their fig4 and fig5

  107. Rob Says:

    Hello Mfon,

    I’m afraid that I don’t have any Matlab code for this.

    Take care, Rob.

  108. pari Says:

    Hi Rob,
    I am trying to simulate the Ergodic rate for slow flat Rayleigh fading channel but my results are a bit different from the paper. I think I am making mistake to apply the ergodicity in simulation. Could you guide me on this? Any Matlab code available for that?

    I am working under a very tight time schedual :((
    Thank you

  109. Rob Says:

    Hi Pari,

    I’m afraid that I don’t have any Matlab code for this - everything that I have is available from this page…

    Take care, Rob.

  110. kuchv Says:

    can i have a code to calculate the capacity of bsc channel

  111. kuchv Says:

    matlab code for capacity of
    binary erasure channel plzzzz

  112. Rob Says:

    Hi Kuchv,

    The capacity of a binary erasure channel with an erasure probability of p is…
    C=1-p

    The capacity of a binary symmetric channel with an error probability of p is…
    C=1-p*log2(1/p)-(1-p)*log2(1/(1-p))

    Take care, Rob.

  113. Miti Says:

    Hi Rob,

    first of all tnx for ur helpful instructions on the capacity of a DCMC.
    I’m confused with the formula u used for the analytic capacity in an AWGN channel. I mean you’ve used C = log2(1+snr). isn’t it actually C = 0.5*log2(1+snr) ?

    Bests, Miti

  114. Rob Says:

    Hi Miti,

    The equation you have given is the capacity if you only use the in-phase part of the carrier. If you also use the quadrature-phase part (like in QAM) then the capacity becomes the equation I gave. You can find more on this at…
    http://en.wikipedia.org/wiki/Shannon–Hartley_theorem

    Take care, Rob.

  115. jigna Says:

    Can you help for the simulation of OFDM for 64-QAM in rayleigh fading channel and find outage capacity & spectral efficiency for that.

  116. Rob Says:

    Hi Jigna,

    I’m afraid that I don’t have any Matlab code for OFDM. But you can convert the following code to 64-QAM…
    http://users.ecs.soton.ac.uk/rm/resources/matlabexit/#comment-1545

    Take care, Rob.

  117. phyuphyu Says:

    Hi Rob,
    I have found many papers that show graphs for capacity versus SNR . However, they have one SNR value. I think we can not plot capacity versus SNR for one value. If we have one received power, we will have one SNR and this received power and capacity depend on one distance value. So we also have one channel matrix and one capacity value. So I m having a lot of trouble for plotting with one SNR value.Please give me some suggestions for plotting this.

  118. rahma Says:

    Hi Rob
    i need a code matlab of calculation capacity a function the interference in network UMTS (3G)
    can you help me!

  119. Rob Says:

    Hi Phyuphyu,

    I’m afraid that I don’t understand what you mean by “one SNR value”. The x axis of a capacity vs SNR plots includes lots of different SNR values…

    Take care, Rob.

  120. Rob Says:

    Hello Rahma,

    I’m afraid that I don’t have any Matlab code for the capacity of an interference channel.

    Take care, Rob.

  121. phyuphyu Says:

    Hi Rob,
    Thank Rob for your reply. Some papers show graphs for capacity vs SNR. In our experiments, we can get one SNR value for one experiment. We make experiments in LOS conditions. So MIMO channel matrix depends on one distance value between transmitter and receiver, antenna spacing, and wavelength. According to this experiments, we can get one received power and thus one SNR value as it depends on received signal power and noise power (SNR= Pr/sigma^2). Therefore, with experimental data, we can’t plot SNR vs capacity because we have one SNR vale and one capacity value.
    I think some papers shows simulation results and I would like to know how we can plot capacity vs SNR with our experiments.
    Thank Rob.
    May be happy and peace

  122. Rob Says:

    Hi Phyuphyu,

    I’m wondering where your value of sigma comes from? If you vary this value, you can vary your noise power and investigate different SNRs…

    Take care, Rob.

  123. maha Says:

    Hi Rob
    i need a code matlab of calculation global capacity in the coexistence DVB-LTE systems (both DVB and LTE are OFDM-based systems) ;
    can you help me!

  124. Sooraj Says:

    Rob,
    I hav calculate SIR for a number of receive antennas (hav taken 20). Nw I need to find outage probabilty. Hw to get it?Finally I need to plot outage probabilty versus no. of receive antennas.

    Regards.
    Sooraj

  125. Rob Says:

    Hello Maha,

    I’m afraid that I don’t have any Matlab code for the situation you describe.

    Take care, Rob.

  126. Rob Says:

    Hello Sooraj,

    The outage probability is given by the fraction of frames for which the channel capacity is below the transmission rate of your system.

    Take care, Rob,

  127. phyuphyu Says:

    Thank Rob,

    sigma^2 is the noise power or variance which is equal No/2 and we can consider Noise power over bandwidth B. So, sigma^2=NoB=KTB (K = Boltzmann’s constant = 1.3803×10-23 [J/K], T = Temperature [K] (Standard Temperature = 290 K, B=bandwidth)). If so, how can I vary noise power?
    Please help me.
    Thank Rob.

  128. Rob Says:

    Hi Phyuphyu,

    Ah, I see. In that case, I would suggest varying the path loss, such that the receiver receives the amount of power that gives you the SNR you want.

    Take care, Rob.

  129. Dina Says:

    Hi Rob,

    I would appreciate some help. I need to calculate the capacity of a binary symmetric channel, and an asymmetric channel. Where should I start from? Also, is there an example of how maximization is done for the mutual information?

    Thanks for your help.
    Dina.

  130. Rob Says:

    Hi Dina,

    You can find all the information you are looking for on Wikipedia…
    http://en.wikipedia.org/wiki/Binary_symmetric_channel#Capacity_of_BSCp
    http://en.wikipedia.org/wiki/Z-channel_(information_theory)#Capacity

    Take care, Rob.

  131. maha Says:

    HI,

    Now I am doing project on cognitive radio spectrum sharing.
    I will be grateful if any one help me by giving some matlab simulation code such as “secondary user ergodic capacity under interference constraints”

  132. Rob Says:

    Hello Maha,

    I’m afraid that I can’t help because I don’t have any Matlab code for cognitive radio.

    Take care, Rob.

  133. maha Says:

    Hello Rob,
    What’s the probability density function of the ratio of two lognormal variables?

  134. Rob Says:

    Hi Maha,

    I’m afraid that I’m not sure. The difference of two normal variables is normal distributed so perhaps the ratio of two lognormal variables is also lognormal distributed (since the log of a ratio of two variables is equal to the difference between the logs of the variables).

    Take care, Rob.

  135. moh99 Says:

    hi dear rob
    i’ve simulated an idma system (it is like cdma) which calculate BER versus SNR.
    now,i wanna to calculate capacity for this system versus snr. how should i do that? should i first calculate snr and then i use it in c=blog(1+snr) or no?
    i was wonder if u help me

  136. Rob Says:

    Hello moh99,

    The equation you have provided will give you the Shannon capacity of an AWGN channel, as plotted in the top figure above. If you would prefer to use the DCMC capacity that corresponds to your modulation scheme, then you can use the simulation that you can download from this page.

    Take care, Rob.

  137. mekus Says:

    dear Rob can you please oblige me with MATLAB CODES to simulate \’throughput\’ graphs for QPSK, 16-QAM and 64-QAM.
    I am carrying out a research to analyze modulation techniques of WCDMA system based on maximum data throughput. From these codes(and simulation), i intend to investigate which of them yields better data throughput.
    God bless you.

    Mekus

  138. Rob Says:

    Hello Mekus,

    Unless I have misunderstood what you are seeking, I think that you are looking for the Matlab code provided above, which can draw the DCMC capacity plots for QPSK, 16QAM, 64QAM, etc. The DCMC capacity is the maximum throughput that these modulation schemes can achieve.

    Take care. Rob.

  139. Ismail Says:

    Hello Rob,

    Thank you for your generous help and for your responses to the questions.
    I am trying to use your code to calculate the channel capacity in a very special case.
    In most cases, in the references books and papers, people suppose that the noise is an additive normal Gaussian wight noise. But in my case the noise is a non Gaussian Impulsive noise. There is not a mathematical formula to calculate its PDF.
    There are two approximations that can be used witch are Middleton Class A or alpha stable distributions. The PDF of the last one is also not defined except for two special cases, Cauchy (parametre α=1)and Gaussien (parametre α=2).

    I was thinking that I may use a similar way to the one that you proposed to calculate the capacity.
    you said that ‘probabilities’ is calculating the probability of each transmitted
    symbol having each possible value. so if we suppose y=x+n then the term
    abs(ones(length(modulation),1)*rx - modulation.’*channel) is actually
    y-x*H=n and
    probabilities= max(e^(-n^2/N0),realmin). and since N0 = 2*sigma^2 then
    probabilities= max(e^(-n^2/2*sigma^2),realmin). Then the sigma factor is the key to calculate the probabilities.

    So I was wondering that if I can some how (maybe empirically) calculate the sigma of my simulated non-Gaussian noise, I could use the same approach that you used to calculate the probabilities and then the capacity. But I am not sure if that is correct and I think that this way is only correct for Gaussian noises.
    I am really stocked with this problem and any help will be appreciated.

  140. Rob Says:

    Hi Ismail,

    The equations that you have mentioned are derived from the Gaussian PDF - that’s where the sigma comes from. For non-Gaussian noise, the probabilities would be obtained using a different equation, having different parameters. In order to measure the capacity, you would need to derive these equations. Any attempt at using an ‘equivalent’ sigma value would only give you an approximation of the channel capacity. It would probably be possible to derive the correct equations for the cases where the noise PDF is defined. However, I’m afraid that I don’t know what to suggest for cases where the PDF is not defined…

    Take care, Rob.

  141. Ismail Says:

    Hello Rob,
    thank you for your fast respond and for the explanations,

    I noticed that the formula that you used to measure the PDF of the Gaussian noise may be missing the (1/sqrt(2*pi*N0)) term. So I think that the ‘probabilities’ factor witch represents the PDF of a normal distribution should be :

    probabilities = max((1/sqrt(2*pi*N0))*
    exp(-(abs(ones(length(modulation),1)*rx - modulation.’*channel).^2)/N0),realmin);

    Also, may I say that if I know the PDF of my noise I can Just replace the above equation with some other corresponding PDF and all the rest will be the same?

    Thank you for your comments.

  142. Rob Says:

    Hi Ismail,

    The term that you mention can be optionally omitted. All it does is normalise the symbol probabilites, such that they sum to one. Many Soft-In Soft-Out (SISO) algorithms (such as the BCJR) don’t care if the probabilities are normalised or not.

    In order to derive an equation for the LLRs when using a different noise distribution, it should be the same process. I would encourage you to figure out the derivation for AWGN first, then apply this process to your different noise distribution.

    Take care, Rob.

  143. Ismail Says:

    Hi Rob,

    Thank you for your help, I will try to do so and see what can I get .

    Have a nice day.

  144. Najwa Says:

    Hello,

    plz i need a matlab code of adaptive coder and modulation ,

    could you giving me idea how it can be done plz?

    Thanks!

  145. Najwa Says:

    Hello,

    plz i need a matlab code related to adaptive modulation and coder could you help me,

    Best regards!

  146. Rob Says:

    Hello Najwa,

    I’m afraid that I don’t have any Matlab code for adaptive coding and modulation. However, you could build this from the coding and modulation Matlab code that I have here. You would just need to produce different parametrisations of the coding and modulation, then switch between them as appropriate.

    Take care, Rob.

  147. nasir Says:

    hi Rob!
    I’m doing research on Ergodic capacity maximization of cognitive Radio network with Quantized channel state information. I have few problems in matlab coding. I’m facing problem to calculate channel gain with feedback bit.
    would you b able to help me please.
    iwill be very thankful to you ..

  148. nasir Says:

    hi maha !

    i m also doing my research in cognitive radio, a relevent title as urs, I m aslo calculating optimum transmit power of secondary user with constraints with parial CSI ..

    Can we be heplful for each other ??

    nasir

  149. Rob Says:

    Hi Nasir,

    I’m afraid that I haven’t done much on cognitive radio or channel capacity for quantized channel state information. You might be able to use my DCMC capactity Matlab code as a starting point, but I’m not sure what the best approach for this would be.

    Take care, Rob.

  150. nasir Says:

    hi Rob,
    Thank you so much for your cooperation. I got alot of help from your this page.

    regads, nasir

  151. pranav Says:

    hi sir i want matlab code that gives the desisgn of channel such that it give varying snr values with random time intervel.

  152. Rob Says:

    Hi Pranav,

    You are describing a fading channel. Simulation of these is built into the Communications toolkit of Matlab - you can read about this here…
    http://uk.mathworks.com/help/comm/ug/fading-channels.html?refresh=true

    Take care, Rob.

  153. Mat Says:

    Hi Rob,

    I used your code to plot the capacity of BPSK, QPSK and 16QAM star and 16 QAM square. Could you help me the equation to plot Shannon line for Rayleigh and AWGN channel.

    Thanks.

    kind regards…

  154. Rob Says:

    Hi Mat,

    You can see code for plotting these lines in my comment above…
    http://users.ecs.soton.ac.uk/rm/resources/matlabcapacity/#comment-5205

    Take care, Rob.

  155. Mat Says:

    Thank you so much Rob.

    Kind regards…

  156. Wang Says:

    Hi Rob,
    Thanks a lot for the explanation you have provided above. It is really helpful. Do you have any codes about DCMC capacity with MIMO channels for different channel distributions?

    Thanks in advance

  157. Rob Says:

    Hello Wang,

    I’m afraid that I don’t have results for MIMO channels. My code could be modified to implement this though…

    Take care, Rob.

  158. Hamed Says:

    Hello Rob,
    Your explanation about DCMC capacity is highly appreciated. I think that eq. 23.23 of Hanzo’s book represents the boundary of modulation capacity with limited Symbol Error Rate, SER, as Shannon,s definition. How can define the bandwidth efficiency of certain modulation technique according to SER? Does this definition true [SE=log2(M)(1-SER)]. Could please provide me references about Spectral efficiency of modulation techniques?

  159. Rob Says:

    Hi Hamed,

    The bandwidth efficiency depends only on the design of the transmitter. The SER also depends on the channel and on the design of the receiver. Owing to this, the bandwidth efficiency is not a direct function of the SER. You may be talking about the maximum bandwidth efficiency that can achieve a particular SER in a particular channel, but I’m afraid that I don’t know of any references for this…

    Take care, Rob.

  160. Mat Says:

    Hi Rob,

    I plotted the capacity of 16 QAM star and square, both modulation schemes should have the same graph?

    Thank you…

    Kind regards…

  161. Rob Says:

    Hello Mat,

    They should have slightly different DCMC capacities - I would expect that square 16QAM is superior for most SNRs.

    Take care, Rob.

  162. sara Says:

    hi i need a matlab code to plot the capacity as a function of average SNR for log-normanl fading with 8db standard deviation ,Rayleigh fading and Nakagami fading with m=2. (regenerate the figure 4.6 , 4.7, 4.8 in wireless communication book for goldsmith)

  163. ASHWINI Says:

    sir can you give me m file script for capacity vs snr , throughput vs snr ,cdf and pdf for 2×1 mimo ofdm system ..i m badly stuck in that ..

    the thing is i m doing my project on simulink platform and thats why not able to write exact m file for simulink model for above mentioned plots.

    plz plz help sir ..my mail id is ashuu.engg@gmail.com

  164. ASHWINI Says:

    i can upload my mimo-ofdm simulink model and its m file for adaptive modulation i just need the formulae for capacity ,throughput ,cdf and pdf plots for my system ..

    where i can upload ? plz let me know

  165. Rob Says:

    Hi Sara,

    I’m afraid that I don’t have Matlab code for plotting the capacity of log-normal fading or Nakagami-m fading. However, you should be able to modify my Rayleigh fading channel capacity code for this. The difficult part is getting the demodulator to accurately estimate the symbol probabilities - you may need to derive these probabilities from scratch. I’m afraid that I have never derived these probabilities, so I can’t help you with this.

    Take care, Rob.

  166. Rob Says:

    Hi Ashwini,

    I’m afraid that I don’t have any Matlab code for the capacity of MIMO channels. I suspect that you will need to write a simulation in order to measure this capacity - I suspect that a closed-form expression cannot be easily found for the capacity of these channels. I’m afraid that I haven’t worked on the capacity of MIMO channels before, so I can’t help you with this.

    Take care, Rob.

  167. ashwini Says:

    hello sir thanks for ur instant response..sir can u plz atleast suggest some book or website where i can get proper help for plotting various graphs for mimo ofdm system in simulink platform ???

    plz help me sir …i m in bad need of some proper direction atleast..i m new to simulink and so unable to plot graphs with the scripts in m file

  168. ashwini Says:

    hello.sir can u plz atleast suggest some book or website where i can get proper help for plotting various graphs for mimo ofdm system in simulink platform ???

    plz help me sir …i m in bad need of some proper direction atleast..i m new to simulink and so unable to plot graphs with the scripts in m file

  169. Rob Says:

    Hi Ashwini,

    I’m afraid that I’ve never used Simulink so I’m not really sure. It seems to me that this might be the best place to get started…
    http://uk.mathworks.com/help/comm/ref/ofdmmodulatorbaseband.html
    http://uk.mathworks.com/help/comm/ref/mimochannel.html
    http://uk.mathworks.com/help/comm/ref/ofdmdemodulatorbaseband.html

    Take care, Rob.

  170. KAS Says:

    HI i am really thankful to everyone here helping each other i really need help if some one can do that for me i want to plot the equations of the following paper….

    Achievable Transmission Capacity of Relay-assisted
    Device-to-Device (D2D) Communication Underlay
    Cellular Networks
    Si WEN, Xiaoyue ZHU, Yanchao LIN, Zhesheng LIN, Xin ZHANG, Dacheng Yang

    specaily equation no..1,3 and 9
    means SINR, Probability and capacity of the system

  171. Minh Says:

    Hi sir
    I want to plot the channel capacity of 8 PAM but the value of spectral efficiency is 2. It mean that i change the distribution of symbols 8 PAM.
    How can I plot the channel capacity curve of this case?

  172. Rob Says:

    Hi Kas,

    I’m afraid that I can’t help you with this, but perhaps somebody else reading this can.

    Take care, Rob.

  173. Rob Says:

    Hi Minh,

    I’m guessing that you are using a 2/3 rate code with 8PAM, in order to achieve a spectral efficiency of 2. In any case, the channel capacity curve is independent of the coding rate. You just need to plot the DCMC capacity curve for 8PAM by modifying my code above. Then you can use this to find the SNR where the capacity becomes equal to your spectral efficiency of 2.

    Take care, Rob.

  174. ASHWINI Says:

    Hi Rob,

    trying to plot throughput vs snr plot for mimo ofdm using the formula t = r(1-ber) where r is code rate.
    getting the graph but throughput scale is not starting with 0 .

    can u suggest me something ??
    or its just ok even if its not starting with zero.

    also tried formula t=r*(1-ber)*log2(M)

    BUT with that just the throughput value increased and yet not started from zero

  175. ASHWINI Says:

    Hello everyone ,

    is there anyone working on LDPC CODES ..
    I WANT HELP REGARDING PLOTTING ITS BER

  176. Rob Says:

    Hello Ashwini,

    I’m afraid that I’m not familiar with the formula t = r(1-ber) - this looks like an equation for goodput, rather than throughput to me. I guess that you are not getting t = 0 because ber doesn’t go higher than 0.5.

    Take care, Rob.

  177. Kas Says:

    I will be great full if anyone can help me please

  178. keshav Says:

    Rob
    please provide matlab code for power allocation in cognitive radio

  179. keshav Says:

    dear Rob
    matlab codes for waterfilling algorithm

  180. Rob Says:

    Hello Keshav,

    I’m afraid that I don’t have any Matlab code for power allocation in cognitive radio, so I can’t help you.

    Take care, Rob.

  181. ashwini Says:

    Hello Rob , thanks for your alwys instant replies .

    can you suggest me the mathematical formula for 1] Throughput for MIMO systems 2] CDF formula and 4] LDPC Sparse matrix .

  182. Rob Says:

    Hi Ashwini,

    My colleague Michael Ng has done lots of work on the throughput of MIMO systems. e.g.
    http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=1608632&tag=1

    For LDPC parity matrix design, I would recommend the following paper…
    http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.125.2561

    Take care, Rob.

  183. ASHWINI Says:

    Thanks a lot Sir , really when i open internet with hopes to get solve my querries this is the place where i collect futher hopes to keep working as someone is helping.

    thanks sir.

    will look into the papers forwarded by you.

  184. Tesla Says:

    Dear Rob,

    I was wondering if you can share with me any reference (book,web, paper) where it is explained why you can use the normalized euclidean distances as transition probabilities in a Gaussian Channel.

    Thank you in advance,

    Nikola

  185. Rob Says:

    Hi Tesla,

    You can see this in “Bit-interleaved coded modulation with iterative decoding” by Xiaodong Li and James A. Ritcey in IEEE Communications Letters, as well as in some of their other work.

    Take care, Rob.

  186. Hos Says:

    Hi Rob,

    Your code works very well but I don’t understand why I can not show it matches the capacity formula. In your code, if we consider A=P(y┃x,h)/P(y┃h), you somehow calculate integral of sum over x of A.log2(A). You know that the capacity is integral on x and h of sum over x of P(x,y,h).log(A). I wonder why yours works. Could you please explain me why A. log2 (A) works?

    Thank you very much

  187. Rob Says:

    Hello Hos,

    I’m afraid that I’m not sure exactly. My histogram code is approximating equation (12) in “Convergence behavior of iteratively decoded parallel concatenated codes” by Stephan ten Brink (IEEE TCOM 2001). I wonder if that paper can help to answer your question. I would also suggest looking at “Extrinsic information transfer functions: Model and erasure channel properties” by Alexei Ashikhmin (IEEE TInfTheory 2004). This paper relates the EXIT chart to the capacity.

    Take care, Rob.

  188. Hos Says:

    Hi Rob,

    Thank you very much. But in equation (12) in “Convergence behavior of iteratively decoded parallel concatenated codes” by Stephan ten Brink (IEEE TCOM 2001), he has P(y┃x,h).log[P(y┃x,h)/P(y┃h)] but you implemented P(y┃x,h)/P(y┃h).log[P(y┃x,h)/P(y┃h)] . Could you please check why this happened. I assume you used Trapezoidal rule for integration but how it simplifies to what you implemented is an important question for me?

    Thank you very much

  189. Rob Says:

    Hi Hos,

    I’m afraid that I don’t follow what you are saying. You are saying that the coefficient of my log term (you have called it P(y┃x,h)/P(y┃h)) is the same as the operand of my log term. But my code is using…
    0.5*pdf(bit_value+1,bin_index)*log2(2.0*pdf(bit_value+1,bin_index)/(pdf(1,bin_index) + pdf(2,bin_index)))

    The coefficient is pdf(bit_value+1,bin_index) and the operand is pdf(bit_value+1,bin_index)/(pdf(1,bin_index) + pdf(2,bin_index)). These are both different. I would argue that they are as Stephan ten Brink suggested.

    Take care, Rob.

  190. Hos Says:

    Dear Rob,

    I really appreciate for your answers. To be on the same page, the link of your code is “http://users.ecs.soton.ac.uk/rm/wp-content/capacity.m” on top of the page. Please let me know if I make a mistake. In your code you are simulating probabilities = probabilities ./ (ones(length(modulation),1)*sum(probabilities));
    This is what I mentioned as P(y┃x,h)/P(y┃h).log[P(y┃x,h)/P(y┃h)].

    This is quite different from what Stephan ten Brink says. You are simulating the total mutual information of channel but Stephan ten Brink talks about bitwise mutual information of channel which is good for analyzing BICM schemes.

    I’m afraid we are not on the same page. Please just check the file on top of this page.

    Thank you very much.

  191. Rob Says:

    Hi Hos,

    Now I understand what you mean. The line you are referring to simply normalises the probabilities. This is necessary since the line above…

    probabilities = max(exp(-(abs(ones(length(modulation),1)*rx - modulation.’*channel).^2)/N0),realmin);

    …produces a matrix in which the columns do not add up to 1. Once we have normalised probabilities, the capacity can be calculated according to…

    channel_capacity = log2(length(modulation))+mean(sum(probabilities.*log2(probabilities)));

    …where the term on the right is the average of the entropy corresponding to each column of the probabilities matrix.

    Does that make sense?

    Take care, Rob.

  192. prathyusha Says:

    Hi Rob,

    Could you please tell me how you plotted the Shannon curve? I tried to plot using the code you’ve mentioned in the above comments. I got a straight line cutting the x-axis. Can you tell me how you got a curve instead of a straight line?

    Thanks

  193. Rob Says:

    Hi Prathysusha,

    It should just be as simple as copying the commands from my comment above (http://users.ecs.soton.ac.uk/rm/resources/matlabcapacity/#comment-5205) into Matlab.

    Take care, Rob.

  194. icha Says:

    Hi Rob ,

    how about the throughput graph for adaptive modulation ? could we make it ?

  195. icha Says:

    I think that i could make it for the adaptive modulation with switching the condition based on the value of SNR

    and could I get the code for througthput DCMC capacity ?
    thank you so much

  196. Rob Says:

    Hi Icha,

    The DCMC capacity curve gives the upper bound for the achievable throughput, which can be fulfilled by combining the modulation with a well designed turbo or LDPC code, for example.

    To get a plot of throughput versus SNR for adaptive modulation, you need to run simulations to find the SNR where you achieve the target BER for each modulation mode. The throughput of the modulation mode is just eta = R*log2(M), where R is the coding rate of your channel code and M is the number of constellation points in your modulator. So, for each modulation mode, you will have a throughput and an SNR. You just plot each of these pairs as points in the plots above.

    Take care, Rob.

  197. Adil Says:

    Sir How can we do simulation in matlab for multipath mimo channel b/w legitimate nodes and eavesdropper to calculate secure bits from the legitimate channel…… plotting bit/channel realization vs number of paths for a given snr?

  198. Rob Says:

    Hi Adil,

    Thank you for your interest in my work, but I haven’t worked on physical layer security before, so I’m afraid that I am unable to help you with this.

    Take care, Rob.

  199. F.Wang Says:

    Dear Rob,

    Thanks for your clarifications,my question concentrate about the maximization of Mutual Information using probabilities {c=max I(X,Y)} ,How I can draw it using transition probability?

  200. Rob Says:

    Hello F.Wang,

    I’m afraid that I’m not sure what you are asking. You can find a discussion of the capacity of binary symmetric channels on Wikipedia…
    https://en.wikipedia.org/wiki/Binary_symmetric_channel#Capacity_of_BSCp

    Take care, Rob.

  201. F.Wang Says:

    Thanks Rob,

    My aim is not the BSC Channel ,is a broadcast AWGN Channel for 2 users ,using your script and form mutual information point of view I want to compute
    C= max I(X,Y1)-I(X,Y2) . Any hint ?
    Best Regards

  202. Rob Says:

    Hi F.Wang,

    I’m afraid that I haven’t worked on the channel capacity for multi-user scenarios, so I don’t have any hints to offer unfortunately.

    Take care, Rob.

  203. Adil Says:

    Thanks Rob; can you help me plotting capacity vs number of paths?

  204. Rob Says:

    Hi Adil,

    I’m afraid that I haven’t worked on the capacity for dispersive channels before.

    Take care, Rob.

  205. majeed Says:

    I have question bout how we can find the analytical expression for the capacity of four point constellation input which are uniform placed.

  206. Rob Says:

    Hi Majeed,

    I’m afraid that I am not aware of a closed-form analytic expression for the DCMC capacity of QPSK (which is what I think you are asking for). I have only ever calculated the capacity using the heuristic method provided in my Matlab code on this webpage.

    Take care, Rob.

  207. Ecace Says:

    Hello Rob,

    The whole post is really interesting. I am consider a QAM constellation with geometric shaping. So some of the symbols in the constellation are eliminated, and some are assigned two binary labels (i.e. the transmission probability is double for some symbols).

    Do you think that this must be taken into account when calculating the average transmit power? (I think it must).

    Thanks

  208. Rob Says:

    Hi Ecace,

    Yes - you should take this into account when calculating the average transmit power.

    Take care, Rob.

  209. Ideal Says:

    Dear Rob,

    After long time, I am contacting. Can I use rician channel parameter instead of rayleigh fading using the following code;

    Let mu = sqrt( K/(2*(K+1)) ) and s = sqrt( 1/(2*(K+1)) )

    r = ( s*randn(1,10000 ) + mu ) + j*( s*randn(1,10000 ) + mu );
    R = abs(r);

  210. Ideal Says:

    Dear Rob,

    I was saying that for the ricican channel, we can replace channel in your matlab script by R as in the above code;
    Let mu = sqrt( K/(2*(K+1)) ) and s = sqrt( 1/(2*(K+1)) )

    r = ( s*randn(1,10000 ) + mu ) + j*( s*randn(1,10000 ) + mu );
    R = abs(r);

    so channel = R; for the Rician channel over a value of K.

  211. Rob Says:

    Hi Ideal,

    If you replace the channel, then you will also need to replace the calculation of the symbol probabilities in the receiver - these are used as the basis of the MI and capacity measurement. I’m afraid that I haven’t done this for the Rician channel before, but I suspect that it would not be too difficult to derive…

    Take care, Rob.

  212. Ideal Says:

    Hi Rob,

    Thanks for the answer,
    Can you provide any reference for the calculation of MI curves assuming the Rician channel? i want to derive that…

  213. Rob Says:

    Hello Ideal,

    The closest reference that I can find is…
    http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=595031

    However, my suggestion would be to figure out how to derive the symbol probabilities for the case of Rayleigh fading, then apply the same process but for Rician fading.

    Take care, Rob.

  214. Huihui Says:

    Hi Rob, thanks for your code. I have a question, this capacity computed considers the modulation, but not the channel coding. If I want to compute the AWGN channel capacity for channel coding rates R_c with BPSK modulation, can I just modify \"N0 = 1/(R_c*10^(snr/10));\"? I also saw someplace that the capacity is given by 1/2*log2(1+2Es/N0), is this correct?

    Thank you very much.

  215. Rob Says:

    Hi Huihui,

    The DCMC capacity depends only on the nature of the input and output of the channel. In other words, it depends on the modulation scheme because this determines the input to the channel. But it doesn’t depend on the channel code.

    Having said that, the conversion from SNR to Eb/N0 does depend on the channel code:

    Eb/N0 = SNR/(R*log2(M))

    SNR = 10^(SNRdB/10)

    where R is the coding rate of the channel code and M is the number of constellation points (2 for BPSK).

    The equation you have given is for a variant of the Shannon capacity, which assumes a Gaussian input to the channel (rather than a BPSK input to the channel).

    Take care, Rob.

  216. Chris Says:

    Hi Rob,
    Thanks very much for sharing your code.
    I have a question on the 16AQM part. In order to normalise the transmitted symbols, you have simply added a factor 1/sqrt(10). shouldn\’t we normalise them one by one? I mean 1/sqrt(18)*(3 + 3i), 1/sqrt(10)*(3 + i), 1/sqrt(2)*(1 + i), and so on. I am really confused. Looking forward to your response.

  217. Rob Says:

    Hi Chris,

    If you normalise them one by one, then you will end up with constellation points on top of each other. In your example you have 1/sqrt(18)*(3 + 3i) and 1/sqrt(2)*(1 + i), but these two complex numbers are identical. We need to normalise the *average* symbol energy, not the instantaneous symbol energy. In this way, the average energy will be 1, even though the instantaneous energy can vary from 2/10 up to 18/10.

    Take care, Rob.

  218. Chris Says:

    Hi Rob,
    Thanks for your rapid response and your explanation. I noticed where I am wrong. I read above comments and figure out that we can use 1/sqrt(mean(abs(mod.Constellation).^2)) to normalise the *average* symbol energy. However, I think this applies only when the symbols are equiprobalbe. For example, 1/sqrt(10) normalises the 16QAM symbols when they are equiprobable. But when they are not equiprobable, we have to normalise them with a different number other than 1/sqrt(10). Am I right?

  219. Rob Says:

    Hi Chris,

    If the symbols are not equiprobable, then you need to weight their energies accordingly.

    Take care, Rob.

  220. Yni Says:

    Hi Rob,

    Can you explain me the equation of these 2 channels m and p using Rayleigh , and how to plot it in matlab, i kinda lost in here…
    help me please!

    ∁ =F(γ_m )- F((γ_m.γ_p)/(γ_m+γ_p ))
    F_x=∫_0^∞▒〖log⁡(1+4)1/x〗 e^((-4)/x) d4 = e^(1/x) E_1 (x^(-1))1/log2

    Regards,YnI.

  221. Rob Says:

    Hello Yni,

    I’m afraid that I don’t have any Matlab code for those equations - they are not ones that I have used in my work.

    Take care, Rob.

  222. Nel Says:

    Hi Rob,

    I have BER data, how to convert that into capacity of the channel. Please give me matlab code

    thanks,
    bye

  223. Rob Says:

    Hello Nel,

    I’m afraid that BER data cannot be converted into the capacity of the channel. BER depends on the whole system. CCMC capacity depends only on the channel, while DCMC capacity depends only on the channel and the modulation scheme.

    Take care, Rob.

  224. SHIVANGI ATREY Says:

    Hello Rob Sir,

    Can you mail me the codes of above graphs. AWGN channel capacity,Uncorrelated Rayleigh Fading Channel capacity and corresponding graphs.

    Thanks and Regards,
    SHIVANGI ATREY

  225. Rob Says:

    Hi Shivangi,

    You can find the code in one of my comments above…
    http://users.ecs.soton.ac.uk/rm/resources/matlabcapacity/#comment-5205

    Take care, Rob.

  226. SHIVANGI ATREY Says:

    Hello Rob Sir,

    I am working to simulate Average Spectral Efficiency V/S Average SNR graph in MIMO OSFBC-OFDM system with the help of this paper which is given below,

    http://ieeexplore.ieee.org/document/5361409/

    But there is a lots of issues.If you have worked on this paper then please give me some guidance.

    Thanks and Regards,
    SHIVANGI ATREY

  227. Rob Says:

    Hello Shivangi,

    I’m afraid that I haven’t worked on the capacity for MIMO, so I can’t help you with this.

    Take care, Rob.

  228. Enock Says:

    Hi Rob,am working on PM-16QAM(capacity of 8),which is basically two 16QAM unions. I have changed the modulation = sqrt(1/20)*[-3-3*i, -3-3*i,…. however may graph still reads Capacity of 4,what parts show i change?Please offer me some guidance..

  229. Rob Says:

    Hi Enock,

    Can you express the union with 256 constellation points? I think that this would work.

    Take care, Rob.

  230. William Says:

    Hi, Rob, thank you very much for sharing the code!
    I want to get the Goodput vs Receiver Es/N0(5-30dB) curves of the adaptive modulation and coding (AMC) in IEEE 802.11a standard. Specifically speaking, four modulation schemes, namely BPSK, QPSK, 16-QAM and 64-QAM, are used. And, convolutional codes with coding rate 1/2 (2/3 for 64-QAM) and 3/4 are adopted. In total, there are eight modulation and coding combinations. And, an AWGN channel is used. How can I get those curves?
    Do you have any codes about that ? (if you have, could you please E-mail the code to me?) Thank you again!

  231. Rob Says:

    Hi William,

    I’m afraid that I don’t have code for generating those curves. But you can obtain them by simulating each combination and measuring the goodput as a function of the channel SNR. Then, for each SNR, you pick the combination that has the best goodput.

    Take care, Rob.

  232. jerry Says:

    Hi Rob, i am trying to plot the channel capacity of msk.
    what will be the modulation of msk in constellation form as you have done for the the various psk.

  233. Rob Says:

    Hello Jerry,

    I haven’t looked at the capacity curve for MSK before, but I suspect that this will be similar to that of QPSK, since both MSK and QPSK give the same BER vs Eb/N0 curve for coherent detection. In Simon Haykin’s book “Digital Communication Systems”, he includes a constellation diagram for MSK that matches the QPSK constellation diagram.

    Take care, Rob.

  234. Joe Says:

    Hey Rob,

    Thanks a lot for posting this, it’s very helpful. I’ve read through the comments above and I’m specifically trying to plot the channel capacity/throughput of an adaptive modulation scheme vs. each constant modulation scheme. I already have simulations to determine SNR thresholds based on a minimum BER constraint. Could I just use the code you have provided here to calculate capacity at each SNR value and adjust the modulation according to the thresholds I have calculated?

    Also, I’d like to calculate capacity over a Rician channel as well. I know in previous comments you had suggested to figure out how symbol probabilities are calculated in Rayleigh fading, then apply the same technique to Rician. Do you have an equation for symbol probabilities in Rician fading or any resources where I can find one to modify in your code?

    Thanks,

    Joe

  235. Rob Says:

    Hi Joe,

    That’s right - you can plot the capacity curves for each modulation scheme separately then get the overall performance for the adaptive modulation scheme by taking the best of the individual modulation schemes at each SNR.

    You can replace the Rayleigh channel model in my code with a Rician channel model. My code uses a heuristic approach, so there is no need to change any of the other equations. However, in one of the comments above, I have provided analytic expressions for the DCMC capacity of a Rayleigh fading channel - I suspect that a similar equation could be derived for a Rician channel, but I haven’t done this before.

    Take care, Rob.

Leave a Reply

Security Code: