Plotting 3D graph
이전 댓글 표시
I am trying to plot a surface graph based on coordinates for x,y and z (I have inserted the data below). So far I have only managed to use the surf function when z is a function of x and y, does anyone know how I would use my data to produe this graph?

답변 (1개)
Star Strider
2021년 2월 5일
Try something like this:
D = readmatrix('YourDataFile.something');
N = 250;
xv = linspace(min(D(:,1)), max(D(:,1)), N);
yv = linspace(min(D(:,2)), max(D(:,2)), N);
[X,Y] = ndgrid(xv,yv);
Z = griddata(D(:,1), D(:,2),D(:,3),X,Y);
figure
surf(X, Y, Z)
shading('interp')
Make appropriate changes to get the result you want.
This should work, and griddata is quite robust, however there could be problems with your data (specifically NaN or Inf elements) that are currently not possible to determine.
.
카테고리
도움말 센터 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!