% demo2 function
function y2 = demo2 (x)
   disp (['in demo2'])
   x  %display x at call
   x = x +2;
   x   %display local x after incrementation
   
   demo3 (x)
   disp (['after return from demo3'])
   x
end   %the end is op;tional here
%demo3 is a subfunction of demo2
function y3 = demo3(y)
   disp (['in demo3 before increment'])
   y
   y = y +3;  %increment
   disp (['in demo3 after increment'])
   y
   disp(['in demo3 nonlocal x ='])
   x
end   %optional