MATLAB: How can i solve the error “Undefined function ‘sign’ for input arguments of type ‘sym’.”

sym sign

i have the following function
function [S] = Signfunciton(f,a,b)
v=-a:0.5:b;
S= f(v);
S=sign(S);
then i give it inputs
>>syms x
>>f(x)=3*x+2
>>Signfunction(f,4,5)
but i always get the error "Undefined function 'sign' for input arguments of type 'sym'."
how can i solve this?? thank you

Best Answer

Do you have the Symbolic Toolbox?
And if you do, why aren't you just doing
syms x;
f = 3*x+2;
sign(subs(f,-4:0.5:5))