Display 3D graph for a function

1 visualización (últimos 30 días)
ly
ly el 15 de Ag. de 2021
Editada: DGM el 15 de Ag. de 2021
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?

Respuesta aceptada

DGM
DGM el 15 de Ag. de 2021
Editada: DGM el 15 de Ag. de 2021
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)

Más respuestas (0)

Categorías

Más información sobre Graph and Network Algorithms en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by