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:
z=[-2:0.01:2];
x=-2:0.1:2;
y=-2:0.1:2;
[X Y]=meshgrid(x,y);
Z = 2.*X.*exp(-(X.^2+Y.^2))
plot3(X,Y,Z);
grid on
Is grid on or grid off required to make a this work? Why do we use it? Is it optional?

 ์ฑ„ํƒ๋œ ๋‹ต๋ณ€

Cris LaPierre
Cris LaPierre 2020๋…„ 11์›” 20์ผ

0 ๊ฐœ ์ถ”์ฒœ

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.

๋Œ“๊ธ€ ์ˆ˜: 2

N/A
N/A 2020๋…„ 11์›” 20์ผ
Ok, thank you. Do you agree that I set this problem up correctly?
N/A
N/A 2020๋…„ 11์›” 24์ผ
Guess so?

๋Œ“๊ธ€์„ ๋‹ฌ๋ ค๋ฉด ๋กœ๊ทธ์ธํ•˜์‹ญ์‹œ์˜ค.

์ถ”๊ฐ€ ๋‹ต๋ณ€ (0๊ฐœ)

์นดํ…Œ๊ณ ๋ฆฌ

๋„์›€๋ง ์„ผํ„ฐ ๋ฐ File Exchange์—์„œ Surface and Mesh Plots์— ๋Œ€ํ•ด ์ž์„ธํžˆ ์•Œ์•„๋ณด๊ธฐ

ํƒœ๊ทธ

์งˆ๋ฌธ:

N/A
2020๋…„ 11์›” 20์ผ

๋Œ“๊ธ€:

N/A
2020๋…„ 11์›” 24์ผ

Community Treasure Hunt

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

Start Hunting!

Translated by