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