0
votes

I'm attempting to plot the function: f(x) = x * e^(x) * cos(x) from 0 to 2*pi. I've tried running:

x = 0:pi/100:2*pi;
y = x*exp(x)*cos(x)

However, every time I attempt to set y. Matlab throws me a 'Error using *' and says Inner matrix dimensions must agree. Any insight into why this happens?

1

1 Answers

1
votes

You have to use .* (element-wise multiplication), not * (matrix multiplication)