##
Matlab listing: `clipdb.m`

The `clipdb()`function prevents the log magnitude of a signal from being too large and negative. (See §J.11 for an example usage.)

function [clipped] = clipdb(s,cutoff) % [clipped] = clipdb(s,cutoff) % Clip magnitude of s at its maximum + cutoff in dB. % Example: clip(s,-100) makes sure the minimum magnitude % of s is not more than 100dB below its maximum magnitude. % If s is zero, nothing is done. clipped = s; as = abs(s); mas = max(as(:)); if mas==0, return; end if cutoff >= 0, return; end thresh = mas*10^(cutoff/20); % db to linear toosmall = find(as < thresh); clipped = s; clipped(toosmall) = thresh;

**Next Section:**

Matlab listing: mps.m and test program

**Previous Section:**

Matlab listing: fold.m