MATLAB: MATLAB function help, input arguments errror

MATLABmatlab function

I'm using matlab, and I'm trying to make a function that gives me the probabilities in a geometric distribution when I enter the values of p, q, and no. of attempts(x) as the inputs.
My function:
function Probability = Geometric(p, q, x)
Probability = p*q^x-1
Now whenever I try to calculate the probability by typing in the values of p, q, and x, such as:
geometric(0.5, 0.5, 1),
it gives me an error about "invalid function for input arguments of type double" sort. Can anyone please help me?
I've tried changing functions, and reducing them to one input and one output.
Please help me someone, and if possible, give me a recommendation on how to make a better function. I thought on making one on the binomial distribution, but it would be difficult to get factorials, and get the probabilities to sum up if I need probabilties for multiple succesess.

Best Answer

After saving your function, add it's path to matlab.
Suppose you saved your function in C:\Users\name\Documents\MATLAB\
addpath('C:\Users\name\Documents\MATLAB\')
Then you should have access to your function.