Matlab Vector Factorial Function

Hi there,

I'm in a thermal physics course this term where we have had a very...short...introduction to Matlab to say the least.

I have to write a simple code for positive integers (assumed) to calculate the factorial of an array, for example, so that I can plot it against the integer value.

My code so far is:

function z = n_fact(N);

z = N;

x = 0;

for count=2:N

x =(N-count+1);

z = x.*z;

end

It can only accept integers...how can I get it so that it iterates individual values of an arary into the function?

Any help would be very much appreciated. Thanks!