MATLAB: Vectorization and plotting user-defined function

MATLABplotuser defined functionvectorization

I am new to MATLAB and am having trouble understanding how to plot userdefined functions.
I have defined a function f via
fun=@(t,r)(t.^2-t.^4).*exp(r.*t.^2);
fun1=@(t,r)exp(r.*t.^2);
f=@(r)integral(@(t)fun(t,r),0,1)./integral(@(t)fun1(t,r),0,1);
Now if I specify say
r=linspace(-10,10);
and type
x=f(r);
I get errors such as
Matrix dimensions must agree.
Error in @(t,r)(t.^2-t.^4).*exp(r.*t.^2)
whereas
x=sin(r);
is accepted. I seem to have been careful to use .* etc. What is the difference between my f and sin, and how do I plot a parametrized graph (f(r),g(r))?

Best Answer

To evaluate the integrals at each value in r,
x = arrayfun(f,r);