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 SolutionsMATLAB: Problem using mesh. “Matrix is singular to working precision.” Actually, the problem is that you do matrix operation but instead, you need to do elementwise operation, which means using ./ and .* instead of / and *. Try this:[X,Y] = meshgrid([-3:0.01:3]); f1=@(X,Y) (3*X.^2.*Y + 10.*X.*Y.^2)./(exp(X.^2) + 3.*Y.^4) - (2.*X.*exp(X.^2).*(X.^3.*Y + 5.*X.^2*Y.^2))./(exp(X.^2) + 3*Y.^4).^2;mesh(X,Y,f1(X,Y)); MATLAB: This function is wrong written F = 3*((1-x).^2).*exp(-x.^2-(y+1).^2); ^ you need this .Read about the difference here:https://www.mathworks.com/help/matlab/matlab_prog/array-vs-matrix-operations.html Related QuestionHelp About Lines in PlotsHow can i plot this equationHow to plot a function like this in matlab
Best Answer