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
Star Strider 2021년 2월 5일

0 개 추천

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.
.

카테고리

태그

질문:

2021년 2월 5일

답변:

2021년 2월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by