The simplest way to do this is using ezplot. To plot the function over the interval , simply type
ezplot('f(x)',[a,b]).
ezplot('x^2*exp(x)',[-1,1]).