matlab 3d function conture

์กฐํšŒ ์ˆ˜: 1 (์ตœ๊ทผ 30์ผ)
budi
budi 2023๋…„ 4์›” 6์ผ
๋‹ต๋ณ€: Nitya Patel 2023๋…„ 6์›” 7์ผ
๐‘ง = โˆ’๐‘ฅ๐‘ฆ๐‘’โˆ’2(๐‘ฅ 2+๐‘ฆ 2 )
-2โ‰คxโ‰ค2 dan -2โ‰คyโ‰ค2!
z=-xy*exp(-^2)*(x.^2+y.^2)
โ†‘
Invalid use of operator.
  ๋Œ“๊ธ€ ์ˆ˜: 1
Rik
Rik 2023๋…„ 4์›” 6์ผ
Are you sure you don't mean x*y?
And what exact is the square of the minus symbol?

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

๋‹ต๋ณ€ (1๊ฐœ)

Nitya Patel
Nitya Patel 2023๋…„ 6์›” 7์ผ
It is my understanding that you want to plot the function for the domain .
Below is the code to plot a 3D surface plot of the function:
% Define the space of x and y. linspace will generate 100 equidistant points from -2 to 2.
x = linspace(-2, 2, 100);
y = linspace(-2, 2, 100);
% Creating a meshgrid. Resulting [X, Y] will give a list of 100x100 points.
[X, Y] = meshgrid(x,y);
% Calculating Z. Note that .* and .^ are used to carry out element-wise operations.
Z = -X .* Y .* exp(-2) .* (X.^2+Y.^2);
% Plotting the function
figure;
surf(X,Y,Z);
xlabel('X');
ylabel('Y');
zlabel('Z');
Moreover, if you want to plot a contour plot, replace the surf function with contour. You can also specify levels of contour as the 4th argument.
figure;
contour(X,Y,Z, 50);
xlabel('X');
ylabel('Y');
colorbar;
Documentation of all the functions can be found here:
  1. surf
  2. contour
  3. meshgrid
  4. linspace

์นดํ…Œ๊ณ ๋ฆฌ

Help Center ๋ฐ File Exchange์—์„œ Line Plots์— ๋Œ€ํ•ด ์ž์„ธํžˆ ์•Œ์•„๋ณด๊ธฐ

ํƒœ๊ทธ

์ œํ’ˆ


๋ฆด๋ฆฌ์Šค

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by