Waterfilling algorithm
% the water-filling process
% x: a vector with each component representing noise power
% P: total power
%
% The returned vector p maximizes the total sum rate given by
% sum(log(1 + p./x)), subject to the power constraint sum(p)== P, p>=0.
%
% The return a vector p also minimizes
% norm(p+x)
% subject to the constraints
% sum(p)==P; p>=0
%
%
% The second output "level" is the water level
%
% Sample usage:
% Three parallel Gaussian channels with noise powers 1, 2 and 3.
% The total power is 2.
%
% >> waterfill([1 2 3],2)
% ans =
% 1.5000 0.5000 0
%
%
% Author: Kenneth Shum, 2010
%
% Reference:
% T. M. Cover and J. A. Thomas, "Elements of Information Theory", John Wiley & Sons, 2006
Cite As
Kenneth Shum (2026). Waterfilling algorithm (https://www.mathworks.com/matlabcentral/fileexchange/28022-waterfilling-algorithm), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
Tags
Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
| Version | Published | Release Notes | |
|---|---|---|---|
| 1.0.0.0 |
