%% Specify Interval of Surface Plot and Plot Piecewise Expression
% Plot the piecewise expression
%  \matrix{{\rm erf}(x) + \cos(y) & -5 < x < 0 \cr \sin(x) + \cos(y) & 0 < x < 5}
% over -5 < y < 5.
% Specify the plotting interval as the second input argument of fsurf. When you plot multiple surfaces over different intervals in the same axes, the axis limits adjust to include all the data.

f1 = @(x,y) erf(x)+cos(y);
fsurf(f1,[-5 0 -5 5])
hold on
f2 = @(x,y) sin(x)+cos(y);
fsurf(f2,[0 5 -5 5])
hold off

% Copyright 2012 The MathWorks, Inc.