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

35 次查看(过去 30 天)
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.

采纳的回答

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

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by