%% Plot Piecewise Expression
% Plot the following piecewise expression by using fplot.
%  y = \Bigg\{ \matrix{-2 & x<-2 \cr x & -2<x<2 \cr 2 & x>2}.

syms x
y = piecewise(x<-2, -2, -2<x<2, x, x>2, 2);
fplot(y)

% Copyright 2012 The MathWorks, Inc.