Looks like you've probably aliased the builtin detrend function...
What do the commands
which detrend
whos detrend
return?
Try
clear detrend
then try the function again...
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!