Contour or mesh plot of irregular-spaced data

9 次查看(过去 30 天)
Hello all,
I have data in the form of 3 vectors (x, y, z). The x and y vectors definitely contain duplicate numbers within each vector, but there are no duplicate x,y pairs. All x,y values are in incremements of 10, but for a given domain, not all the points are available. Example data:
For 0<= x,y <= 20
x = [0, 0, 0, 10, 10, 20, 20];
y = [0, 10, 20, 0, 20, 0, 10];
z = [20, 10, 40, 50, 10, 30];
Is there an easy way to plot the z values for given x,y coordinates? If not, two others other things I could try:
1) I know the mesh and surf functions can be used to plot irregular spaced data (here), but they require matrices as inputs. Is there an easy way to convert the vector data I have into matrix form so I can use the mesh function?
2) I could linearly interpolate the z values for the x,y pairs that are missing, but this seems like a last resort.

回答(1 个)

darova
darova 2019-10-25
Use griddata to convert your vectors into matrices

类别

Help CenterFile Exchange 中查找有关 Contour Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by