To define a function in matlab you can do following syntax of given function:
function n = F(x)
that is it. You can put end at the end of function. But it is also acceptable not to put to various matlab versions. If you put end for one function then you have to put for all function in single m file.
then you can generate random numbers, either integer or double, and can get the values of this function.