필터 지우기
필터 지우기

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

조회 수: 15 (최근 30일)
SugerCodeCude
SugerCodeCude 2020년 10월 5일
댓글: Star Strider 2020년 10월 6일
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!
Star Strider
Star Strider 2020년 10월 6일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (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