4 views (last 30 days)
N/A on 20 Nov 2020
Commented: N/A on 24 Nov 2020
Consider a function 𝑧 = 2𝑥exp((𝑥^2+𝑦^2)) with x and y on [-2, 2]. Create a line plot in 3-d using plot3(X,Y,Z).
Here is my code so far, please recommend how I fix this:
[X Y]=meshgrid(x,y);
Z = 2.*X.*exp(-(X.^2+Y.^2))
grid on
Is grid on or grid off required to make a this work? Why do we use it? Is it optional?

Accepted Answer

Cris LaPierre
Cris LaPierre on 20 Nov 2020
With plot3, you do not have to use meshgrid. Just create a vector a X values, a vector of Y values, and compute your Z values from the equation.
Whether grid needs to be on or off is up to whomever is grading your assignment. When it is on, it adds a grid to the axes. It does not affect how the plot behaves, just it's appearance.
N/A on 24 Nov 2020
Guess so?

Sign in to comment.

More Answers (0)


Find more on Printing and Saving in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!