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