Display 3D graph for a function

조회 수: 1 (최근 30일)
ly
ly 2021년 8월 15일
편집: DGM 2021년 8월 15일
Display a 3D graph for a function
x3 = 0;
nc=10;
y1 = 43.5943 - 12.5921*x1 + 4.08342*x2 + 3.6128*x3 + 14.4637* x1^2 + 9.3*x1*x2+ 4.1225*x1*x3 + 12.5333*x2^2 +3.2325* x2*x3+ 15.7648* x3^2;
[x1,x2] = meshgrid((1.68*(-1:1/nc:1)),(1.68*(-1:1/nc:1)));
mesh (x1,x2,y1)
But I got a figure which is not similar to the example.
How to display a function correctly?

채택된 답변

DGM
DGM 2021년 8월 15일
편집: DGM 2021년 8월 15일
You probably weren't intending to use matrix operations there.
x3 = 0;
nc = 10;
[x1,x2] = meshgrid((1.68*(-1:1/nc:1)),(1.68*(-1:1/nc:1)));
% use .* and .^ for elementwise operations
y1 = 43.5943 - 12.5921*x1 + 4.08342*x2 + 3.6128*x3 ...
+ 14.4637*x1.^2 + 9.3*x1.*x2 + 4.1225*x1.*x3 ...
+ 12.5333*x2.^2 + 3.2325*x2.*x3 + 15.7648*x3.^2;
mesh (x1,x2,y1)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Directed Graphs에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by