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 Center および File ExchangeDirected Graphs についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by