%To show an example of vectorizing at work, 
%consider writing an M-file that will clip an input signal to
%given upper and lower limits. 
%The code from a conventional language would look like the following
%in MATLAB:
function y = clip( x, lo, hi )
% CLIP --- threshold large and small elements in matrix x
% ==========> SLOWEST POSSIBLE VERSION <================
%
[M,N] = size(x);
y = uint8(zeros(M,N));
for m = 1:M
    for n = 1:N
        if x(m,n) > hi
            x(m,n) = hi;
        elseif x(m,n) < lo
        x(m,n) = lo;
        end, 
    end, 
end
y=x;