MATLAB: Creating a simple plot

plot

Im trying to plot y=x*e^(-x^2) where the range of x is from -3,3
Ive tried running
x = -3:3; y = x*exp(-x.^2); plot (x, y) however i keep getting the error Inner matrix dimensions must agree. Not quite sure what that means

Best Answer

Use .* instead of * here:
y = x.*exp(-x.^2);
Also, you will want higher resolution:
x = -3:0.01:3;
Related Question