Based on the water filling algorithm discussed in class plea
Based on the water filling algorithm discussed in class, please write a Matlab function to implement the water filling algorithm. For simplicity, let B_k = N_0 = 1 so that the effective noise becomes n_k = 1/g_k. Denote K as the number of parallel channels, the two input arguments should be power gain vector q = [q_L, g_2, ... g_k] and the total transmitting power P; the output argument should be the optimal power allocation vector p = [p_1, P_2, ...p_k] and the total channel capacity C. Assume P=1 and the channel power gain vector is g= [6.8945 2.5680 6.1508], please calculate the optimal power allocation vector p = [p_1, P_2, ...p_k] and the total channel capacity C. Assume P=2 and the channel power gain vector is g= [4.6634 0.3885 0.7282 2.2971 0.1021 6.7367 1.6477 1.9270], please calculate the optimal power allocation vector p = [p_1, P_2, ...p_k] and the total channel capacity C. Assume P=10 and the channel power gain vector is g= [3.3547 1.4277 1.6167 0.8729 0.6868 0.5629 2.5745 0.7722 0.8459 3.6328 4.2573 1.3928 0.0822 2.1554 1.0714 2.9939 0.5720 2.7322 1.3626 0.7160], please calculate the optimal power allocation vector p = [p_1, P_2, ...p_k] and the total channel capacity C.
Solution
MATLAB CODE:
