Borrar filtros
Borrar filtros

Plotting Multivariable x, y, and z for a data set

15 visualizaciones (últimos 30 días)
SugerCodeCude
SugerCodeCude el 5 de Oct. de 2020
Comentada: Star Strider el 6 de Oct. de 2020
I have made a 3d multivatiable gird that is, x, y, and z
grid_x = 1:1:10;
grid_y = 1:1:10;
grid_z = 1:1:10;
then in a 3 loop (3d multivariable) I calculate values for a give equation and save is it in a variable called values(:,:). the multivariable values has points between 1:10 random numbers
Now I have used
[X,Y] = meshgrid(grid_x,grid_y);
Z = griddata(grid_x,grid_y,grid_z,X,Y);
however Z is not where the values are, when I call
surf(X,Y,Z)
I get a empty plot in 3d, here is where I am not understand how to call in the data points which is called values, even when I did
surf(X,Y,Z,values(:,:))
I get a empty plot in 3d.
Please tell me to clarify if needed.

Respuesta aceptada

Star Strider
Star Strider el 5 de Oct. de 2020
The problem is with your choice of coordinates.
When I ran your code, it threw:
Warning: The underlying triangulation is empty - the points may be collinear.
> In griddata>useScatteredInterp (line 183)
and ‘Z’ was empty.
Creating random values instead resulted in the sort of result you want:
grid_x = rand(1,50);
grid_y = rand(1,50);
grid_z = randn(size(grid_x));
[X,Y] = meshgrid(0:0.01:1, 0:0.01:1);
Z = griddata(grid_x,grid_y,grid_z,X,Y);
figure
surf(X,Y,Z)
grid on
.
  13 comentarios
SugerCodeCude
SugerCodeCude el 6 de Oct. de 2020
Thank you so mch, this back and forth help me understand the issues I was having. Thank you again!
Star Strider
Star Strider el 6 de Oct. de 2020
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements 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