function [y,z] = foo1(x)

% filename: xyz.m
% author: Kadin
% purpose: demonstrate relationship between file and function names
% foo1 invoked as [y,z]=xyz(x)
y = x+2;
z = foo2(y);

function y = foo2(x)   % subfunction; not visible outside xyz.m
persistent p;   % preserves value of p between calls
if isempty(p)   % call foo1 only once to prevent recursive ops
p = 1;
y = xyz(x);  % foo1 is always invoked as xyz
else
y = x*2;
end
