MATLAB: Am I getting undefined variable error

Best Answer

How are you calling your function? If you are just clicking the big green 'Run' at the top then of course you will get this error. Your function takes 'x' as an input argument. If you don't supply it by calling the function from command line or another function then it won't exist.
Related Question