%
% Example of a function that first generates random numbers
%      and then calls a subfunction to calculate their mean
%
% Author: Xin-Zhong Liang, 2012-08-25
%
function sub_ex()
for i =1:100
    a(i) = rand();
end
m = mean_ex(a,i);
fprintf('Mean is %f.',m);
end

function m = mean_ex(a,i)
m = sum(a)/i;
end
