MATLAB: How do at write the equation

matlab function elementary vector

How do I make this equation work for a vector? (the vector x=[-1:0.1:1])
f = x 2 sin(πx)
I've tried the following:
f=x.^2*sin(x.*pi)
f=x.^2*sin(x*pi)
It doesn't work.

Best Answer

f = x.^2.*sin(x*pi)
Related Question