matlab fuction code example Example: matlab function function ave = average(x) ave = sum(x(:))/numel(x); end