Contour or mesh plot of irregular-spaced data

10 views (last 30 days)
Vivek Gupta
Vivek Gupta on 24 Oct 2019
Answered: darova on 25 Oct 2019
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.

Answers (1)

darova
darova on 25 Oct 2019
Use griddata to convert your vectors into matrices

Categories

Find more on Contour Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!