Contour or mesh plot of irregular-spaced data

조회 수: 4 (최근 30일)
Vivek Gupta
Vivek Gupta 2019년 10월 24일
답변: darova 2019년 10월 25일
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에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by