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?

Risposte (1)

Star Strider
Star Strider il 5 Feb 2021

0 voti

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

Tag

Richiesto:

il 5 Feb 2021

Risposto:

il 5 Feb 2021

Community Treasure Hunt

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

Start Hunting!

Translated by