How do you create a function file in MATLAB? code example Example: how to write a function in matlab function f = fact(n) f = prod(1:n); end