1 – for troubleshooting, type n before you execute the function. See if Matlab comes back with 1 to doublecheck whether Matlab is seeing the correct value of n.
2 – I’m not sure if it makes a difference to y our question, but I thought an end statement is required at the end of a function.
=====================================
Eng-tips forums: The best place on the web for engineering discussions.