Azzera filtri
Azzera filtri

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

15 visualizzazioni (ultimi 30 giorni)
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.

Risposta accettata

Star Strider
Star Strider il 5 Ott 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 Commenti
SugerCodeCude
SugerCodeCude il 6 Ott 2020
Thank you so mch, this back and forth help me understand the issues I was having. Thank you again!

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by