Very useful code. Thank you! But one little problem is that random is not provided, and when replaced by 1/sqrt(2) * abs(randn(nr,nt) + j*randn(nr,nt) ), the figure obtained is not similar to the one expected. The capacity is linear! Can someone please tell me how to fix this? thanks in advance!!